我有wamp server2,但我安裝了phpmailer5會導致任何問題? 我的php.ini 我用this sitesmtp的PHP郵件沒有響應
這裏是代碼:
<?php
require_once('./PHPMailer_v5.1/class.phpmailer.php');
define('GUSER','[email protected]'); // GMail username
define('GPWD','mypass'); // GMail password
function smtpmailer($to, $from, $from_name, $subject, $body) {
global $error;
$mail = new PHPMailer(); // create a new object
$mail->IsSMTP(); // enable SMTP
$mail->SMTPDebug = 0; // debugging: 1 = errors and messages, 2 = messages only
$mail->SMTPAuth = true; // authentication enabled
$mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for GMail
$mail->Host = 'smtp.gmail.com';
$mail->Port = 25;
$mail->Username = GUSER;
$mail->Password = GPWD;
$mail->SetFrom($from, $from_name);
$mail->Subject = $subject;
$mail->Body = $body;
$mail->AddAddress($to);
if(!$mail->Send()) {
$error = 'Mail error: '.$mail->ErrorInfo;
return false;
} else {
$error = 'Message sent!';
return true;
}
}
smtpmailer('[email protected]','[email protected]', 'phpmailer', 'test mail message', 'Hello World!');
if (smtpmailer('[email protected]','[email protected]', 'phpmailer', 'test mail message', 'Hello World!')) {
echo "sent";
}
if (!empty($error)) echo $error;
?>
這裏是輸出:
SMTP Error: Could not connect to SMTP host. SMTP Error: Could not authenticate. Mail error: SMTP Error: Could not authenticate.
然後我去爲php.ini並設定SMTPSERVER爲SMTP .google.com
SMTP = smtp.google.com
再次沒有變化
phpmailer不使用php.ini郵件設置。這些用於通常沒有安裝本地MTA並且必須使用外部服務的Windows盒子。 – 2012-02-23 19:00:27
那有什麼問題?更改php.ini之前我也有問題 – Nickool 2012-02-23 19:03:27
我有Windows系統 – Nickool 2012-02-23 19:10:19