【发布时间】:2013-11-19 03:23:09
【问题描述】:
请帮忙,我已经发布了一个关于这个问题的相关问题。我有一个没有错误的代码和一条消息:
SMTP -> FROM SERVER:220 itech.urc.local Microsoft ESMTP MAIL Service, Version: 6.0.3790.3959 ready at Thu, 7 Nov 2013 20:44:46 +0800
SMTP -> FROM SERVER: 250-itech.urc.local Hello [192.168.56.100] 250-AUTH GSSAPI NTLM LOGIN 250-AUTH=LOGIN 250-TURN 250-SIZE 250-ETRN 250-PIPELINING 250-DSN 250-ENHANCEDSTATUSCODES 250-8bitmime 250-BINARYMIME 250-CHUNKING 250-VRFY 250 OK
SMTP -> FROM SERVER:250 2.1.0 itechweb-mail@itechglobal.com.ph....Sender OK
SMTP -> FROM SERVER:250 2.1.5 algie.rosario@yahoo.com
SMTP -> FROM SERVER:354 Start mail input; end with .
SMTP -> FROM SERVER:250 2.6.0 <7319fa99244aea2045353a8769d0f46b@192.168.56.100> Queued mail for delivery
Message sent
这是我的代码:
<?php
include('PHPMailer_5.2.0/class.phpmailer.php');
include('PHPMailer_5.2.0/class.smtp.php');
$mail = new PHPMailer();
$body = file_get_contents('PHPMailer_5.2.0/examples/contents.html');
$body = eregi_replace("[\]",'',$body);
$mail->IsSMTP(); // telling the class to use SMTP
$mail->Host = "linkmpr01.urc.local"; // SMTP server
$mail->SMTPDebug = 2; // enables SMTP debug information
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->Host = "whatever.local"; // sets the SMTP server
$mail->Port = 25; // set the SMTP port for the GMAIL server
$mail->Username = "whatever"; // SMTP account username
$mail->Password = "whatever"; // SMTP account password
$mail->SetFrom('ethnicweb-mail@ethnicglobal.com.ph', 'First Last');
$mail->AddReplyTo("ethnic-mail@ethnicglobal.com.ph","First Last");
$mail->Subject = "PHPMailer Test Subject via smtp, basic with authentication";
$mail->AltBody = "To view the message, please use an HTML compatible email viewer!";
$mail->MsgHTML($body);
$address = "algie.rosario@yahoo.com";
$mail->AddAddress($address, "John Doe");
$mail->AddAttachment("PHPMailer_5.2.0/examples/images/phpmailer.gif");
$mail->AddAttachment("PHPMailer_5.2.0/examples/images/phpmailer_mini.gif");
if(!$mail->Send())
{
echo "Mailer Error: " . $mail->ErrorInfo;
}
else
{
echo "Message sent!";
}
此代码适用于我,唯一的问题是它没有向收件人发送任何内容。请帮忙。
【问题讨论】:
-
删除用户名和密码!您可能正在共享敏感数据。其次,请检查对服务器(主机)的身份验证是否有效。
-
设置 $mail->SMTPDebug = 2;顺便问一下,这个 linkmpr01.urc.local 是哪个 SMTP 服务器 URL?并检查是否需要 TLS 并用下一行测试一次。 $mail->SMTPSecure = "tls";
-
@Pramod - 抱歉,我尝试删除/更改我的密码和用户名,但出现“SMTP -> 错误:服务器不接受用户名”。我还尝试更改我的服务器/主机,并显示“无法连接到 SMTP 主机”。因此,我认为该区域没有任何问题。我还尝试使用 MS Outlook(也是服务器/主机)发送外部收件人,它工作正常。
-
@Pramod - 如果您分析并阅读了上面的代码,$mail->SMTPDebug 已经设置为 2。如果我添加 $mail->SMTPSecure = "tls",则会出现类似错误“SMTP -> FROM SERVER:554 5.7.3 Unable to initialize security subsystem”以及 $mail->SMTPSecure = “tls” 显示“SMTP -> ERROR: Failed to connect to server: (0)”;跨度>
-
linkmpr01.urc.local 是我们 Outlook 女士的主机/服务器。
标签: php linux smtp phpmailer smtp-auth