您好,我想用 hotmail 帐户发送邮件,我得到:
SMTP -> FROM SERVER:220 mx.google.com ESMTP q44sm31046347eep.5
SMTP -> FROM SERVER: 250-mx.google.com at your service, [91.203.134.106] 250-SIZE 35882577 250-8BITMIME 250-AUTH LOGIN PLAIN XOAUTH XOAUTH2 250-ENHANCEDSTATUSCODES 250 PIPELINING
SMTP -> FROM SERVER:502 5.5.1 Unrecognized command. q44sm31046347eep.5
SMTP -> ERROR: STARTTLS not accepted from server: 502 5.5.1 Unrecognized command. q44sm31046347eep.5
SMTP -> FROM SERVER:250 2.1.5 Flushed q44sm31046347eep.5
Language string failed to load: tls
我根本不知道为什么会有 mx.google.com !!!这是我的代码
require_once('phpmailer/class.phpmailer.php');
$defport=25;
$sendmail='MAIL@hotmail.com';
$mailpass='PASS';
$mail = new PHPMailer(true);
try {
$mail->IsSMTP(); // send via SMTP
$mail->Mailer = "smtp";
if($defport==25) $mail->SMTPSecure = "tls";
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->SMTPDebug = 2;
$mail->Host = 'smtp.live.com';
$mail->Port = 25;
$mail->Username = $sendmail; // SMTP username
$mail->Password = $mailpass; // SMTP password
$mail->From = $sendmail;
$mail->FromName = $sendmail;
$mail->Subject = 'test';
$mail->Body = 'test';
$mail->WordWrap = 50;
$mail->AddAddress ('foo@foo.bar.com');
$mail->IsHTML (true);
$mail->SetLanguage("en", "phpmailer/language/");
$mail->CharSet = 'utf-8';
$mail->Send();
echo "Message Sent OK\n";
} catch (phpmailerException $e) {
echo $e->errorMessage(); //Pretty error messages from PHPMailer
} catch (Exception $e) {
echo $e->getMessage(); //Boring error messages from anything else!
}
?>
你知道这可能是错的吗?
我尝试了另一个版本的 phpmailer (5.2.2) 并收到以下错误:
Warning: preg_match() [function.preg-match]: Compilation failed: reference to non-existent subpattern at offset 626 in ***/phpmailer/class.phpmailer.php on line 738
Invalid address: foo@foobar.bar.com
第 738 行是:
return preg_match('/^(?!(?>(?1)"?(?>\\\[ -~]|[^"])"?(?1)){255,})(?!(?>(?1)"?(?>\\\[ -~]|[^"])"?(?1)){65,}@)((?>(?>(?>((?>(?>(?>\x0D\x0A)?[ ])+|(?>[ ]*\x0D\x0A)?[ ]+)?)(\((?>(?2)(?>[\x01-\x08\x0B\x0C\x0E-\'*-\[\]-\x7F]|\\\[\x00-\x7F]|(?3)))*(?2)\)))+(?2))|(?2))?)([!#-\'*+\/-9=?^-~-]+|"(?>(?2)(?>[\x01-\x08\x0B\x0C\x0E-!#-\[\]-\x7F]|\\\[\x00-\x7F]))*(?2)")(?>(?1)\.(?1)(?4))*(?1)@(?!(?1)[a-z0-9-]{64,})(?1)(?>([a-z0-9](?>[a-z0-9-]*[a-z0-9])?)(?>(?1)\.(?!(?1)[a-z0-9-]{64,})(?1)(?5)){0,126}|\[(?:(?>IPv6:(?>([a-f0-9]{1,4})(?>:(?6)){7}|(?!(?:.*[a-f0-9][:\]]){7,})((?6)(?>:(?6)){0,5})?::(?7)?))|(?>(?>IPv6:(?>(?6)(?>:(?6)){5}:|(?!(?:.*[a-f0-9]:){5,})(?8)?::(?>((?6)(?>:(?6)){0,3}):)?))?(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])(?>\.(?9)){3}))\])(?1)$/isD', $address);
希望有人能弄清楚