<?php
require("./PHPMailer/class.phpmailer.php");
global $error;
$from = $_REQUEST['from'];
$from_name = $_REQUEST['from_name'];
$subject = $_REQUEST['subject'];
$body = $_REQUEST['body'];
$is_gmail = $_REQUEST['is_gmail'] =true;
$to = $_REQUEST['to'];
$to = "[email protected]"; // used for testing only
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPAuth = true;
if ($is_gmail) {
$mail->SMTPSecure = 'tls';
$mail->Host = 'smtp.ks101.fdsfd.eu';
$mail->Username = '[email protected]';
$mail->Password = "pass";
$mail->SMTPDebug = 1;
} else {
$mail->Host = SMTPSERVER;
$mail->Username = SMTPUSER;
$mail->Password = SMTPPWD;
}
$mail->SetFrom($from, $from_name);
$mail->Subject = $subject;
$mail->Body = $body;
$mail->AddAddress($to);
if(!$mail->Send()) {
$error = 'Mail error: '.$mail->ErrorInfo;
echo(false);
return false;
} else {
$error = 'Message sent!';
echo(true);
return true;
}
?>
我顯示以下代碼託管提供商,他們告訴我它應該工作。我嘗試上傳,但沒有奏效。有人可以幫我發送郵件在PHP
當我嘗試網站應該是(實際上可能是PHP服務器)的實際服務器時,我得到了錯誤。
<br />
<b>Warning</b>: stream_socket_enable_crypto() [<a href='streams.crypto'>streams.crypto</a>]: this stream does not support SSL/crypto in <b>/home/www/web420/html/test/PHPMailer/class.smtp.php</b> on line <b>197</b><br />
SMTP -> ERROR: RSET failed:
<br />Language string failed to load: tls
當我嘗試我的服務器我得到了相同的代碼錯誤上(IIS 7)
<br />
<b>Warning</b>: stream_socket_enable_crypto() [<a href='streams.crypto'>streams.crypto</a>]: this stream does not support SSL/crypto in <b>C:\inetpub\vhosts\test.com\subdomains\test\httpdocs\appbounce\PHPMailer\class.smtp.php</b> on line <b>197</b><br />
我不知道什麼是該網站所使用的服務器。我得到了不同的-2錯誤。請有人驗證,如果他們是我的代碼中的問題。我究竟需要做什麼。
感謝
郵件();工作嗎? http://www.php.net/manual/en/function.mail.php – Michas 2012-03-02 13:54:41
嘿@Michas你能告訴我如何設置密碼嗎? – user1240424 2012-03-02 14:04:28
如果你很幸運並且在PHP服務器上配置了郵件,它將無需密碼。 – Michas 2012-03-02 14:17:10