【问题标题】:Cannot send emails with phpmailer - smtp.com无法使用 phpmailer 发送电子邮件 - smtp.com
【发布时间】:2018-05-22 15:21:13
【问题描述】:

我无法使用我们使用的 smtp 服务器发送电子邮件。

编辑:起初我收到错误 getaddrinfo failed: name or service not known, 但已修复。但我仍然收到以下错误。

Server: send.smtp.com
Port: 25
Use encrypted protocol: No
Authentication: requires username/password 

我尝试过的事情:

  • 在 smtp.com 上与支持人员验证设置
  • 尝试了不同的端口(80、2525)
  • 在运行我的 apache 服务器 (RHEL 7) 的机器上暂时禁用了我的防火墙
  • 使用 IP 地址作为服务器地址

当我尝试发送测试电子邮件时,我收到:

SMTP -> FROM SERVER: 
SMTP -> FROM SERVER: 
SMTP -> ERROR: EHLO not accepted from server: 
SMTP -> FROM SERVER: 
SMTP -> ERROR: HELO not accepted from server: 
SMTP -> ERROR: AUTH not accepted from server: 

object(SMTP)#35 (7) { 
  ["SMTP_PORT"]=> int(25) 
  ["CRLF"]=> string(2) " " 
  ["do_debug"]=> bool(true) 
  ["do_verp"]=> string(2) "on" 
  ["smtp_conn":"SMTP":private]=> resource(474) of type (stream) 
  ["error":"SMTP":private]=> array(3) { 
    ["error"]=> string(29) "AUTH not accepted from server" 
    ["smtp_code"]=> bool(false) 
    ["smtp_msg"]=> bool(false) 
  } 
  ["helo_rply":"SMTP":private]=> NULL 
} 

SMTP -> NOTICE: EOF caught while checking if connected 
SMTP -> FROM SERVER: 
SMTP -> FROM SERVER: 
SMTP -> ERROR: EHLO not accepted from server: 

SMTP -> FROM SERVER: 
SMTP -> ERROR: HELO not accepted from server: 
SMTP -> ERROR: AUTH not accepted from server: 

object(SMTP)#35 (7) { 
  ["SMTP_PORT"]=> int(25) 
  ["CRLF"]=> string(2) " " 
  ["do_debug"]=> bool(true) 
  ["do_verp"]=> string(2) "on" 
  ["smtp_conn":"SMTP":private]=> resource(476) of type (stream) 
  ["error":"SMTP":private]=> array(3) { 
    ["error"]=> string(29) "AUTH not accepted from server" 
    ["smtp_code"]=> bool(false) 
    ["smtp_msg"]=> bool(false) 
  } 
  ["helo_rply":"SMTP":private]=> NULL 
} 

SMTP -> NOTICE: EOF caught while checking if connected

我可以远程登录:

# telnet send.smtp.com 25
Trying 192.40.165.68
Connected to send.smtp.com
Escape character is '^]'

编辑:在 /var/log/maillog 中看到了这个

May 23 08:20:38 txapone sendmail[68217]: w4MHtNJF053686: to=<me@mydomain.com>, ctladdr=<apache@server.domain.local> (48/48), delay=18:25:15, xdelay=00:00:40, mailer=relay, pri=1740402, relay=send.smtp.com [192.40.165.69], dsn=4.0.0, stat=Deferred: Connection reset by send.smtp.com
May 23 08:20:38 txapone sendmail[68217]: w4MHvv5c053871: to=<me@mydomain.com>, ctladdr=<apache@server.domain.local> (48/48), delay=18:22:40, xdelay=00:00:00, mailer=relay, pri=1740402, relay=send.smtp.com, dsn=4.0.0, stat=Deferred: Connection reset by send.smtp.com
May 23 08:20:38 txapone sendmail[68217]: w4MHakO3053279: to=<me@mydomain.com>, ctladdr=<apache@server.domain.local> (48/48), delay=18:43:52, xdelay=00:00:00, mailer=relay, pri=1830402, relay=send.smtp.com, dsn=4.0.0, stat=Deferred: Connection reset by send.smtp.com
May 23 08:20:38 txapone sendmail[68217]: w4MHcf5U053351: to=<me@mydomain.com>, ctladdr=<apache@server.domain.local> (48/48), delay=18:41:57, xdelay=00:00:00, mailer=relay, pri=1830402, relay=send.smtp.com, dsn=4.0.0, stat=Deferred: Connection reset by send.smtp.com
May 23 08:20:38 txapone sendmail[68217]: w4MHmc4h053590: to=<me@mydomain.com>, ctladdr=<apache@server.domain.local> (48/48), delay=18:32:00, xdelay=00:00:00, mailer=relay, pri=1830402, relay=send.smtp.com, dsn=4.0.0, stat=Deferred: Connection reset by send.smtp.com
May 23 08:22:46 txapone sendmail[68288]: w4NCMkVH068288: from=apache, size=121, class=0, nrcpts=1, msgid=<201805231222.w4NCMkVH068288@txapone.tframes.local>, relay=apache@localhost
May 23 08:22:46 txapone sendmail[68289]: w4NCMk5M068289: from=<apache@server.domain.local>, size=402, class=0, nrcpts=1, msgid=<201805231222.w4NCMkVH068288@txapone.tframes.local>, proto=ESMTP, daemon=MTA, relay=localhost [127.0.0.1]
May 23 08:22:46 txapone sendmail[68288]: w4NCMkVH068288: to=me@mydomain.com, ctladdr=apache (48/48), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30121, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (w4NCMk5M068289 Message accepted for delivery)
May 23 08:23:27 txapone sendmail[68291]: w4NCMk5M068289: to=<me@mydomain.com>, ctladdr=<apache@server.domain.local> (48/48), delay=00:00:41, xdelay=00:00:41, mailer=relay, pri=120402, relay=send.smtp.com [192.40.165.68], dsn=4.0.0, stat=Deferred: Connection reset by send.smtp.com

这是我正在使用的 PHP 脚本:

<?php
require("src/PHPMailer.php");
require("src/SMTP.php");
require("src/Exception.php");
$mail = new PHPMailer\PHPMailer\PHPMailer();
$mail->IsSMTP();
$mail->Host = "send.smtp.com"; 
$mail->SMTPAuth = true; 
$mail->Username = "webmaster@domain.com"; 
$mail->Password = "pwd";
$mail->Port = "25";
$mail->From = "notification@domain.com"; 
$mail->FromName = "Company"; 
$mail->AddAddress("allisonc@domain.com", "Me"); 
$mail->AddReplyTo("notification@domain.com", "Company"); 
$mail->WordWrap = 50; 
$mail->IsHTML(false); 
$mail->Subject = "SMTP.com Test";
$mail->Body = "SMTP.com Test Message!";
$mail->Timeout = 30;
$mail->SMTPDebug = 4;
$mail->SMTPSecure = FALSE;
$mail->SMTPAutoTLS = FALSE;
if(!$mail->Send())
{
 echo "Message could not be sent. <p>";
 echo "Mailer Error: " . $mail->ErrorInfo;
 var_dump($mail);
 //exit;
}
else
{
  echo "Message has been sent";
}


echo "<hr>";

$success = mail('allisonc@domain.com', 'Test Mail function', 'Test Mail function');
if (!$success) {
  echo "mail failed";
    $errorMessage = error_get_last()['message'];
    var_dump($errorMessage);
}
var_dump($success);

如果您需要更多信息/测试,请告诉我。

【问题讨论】:

    标签: smtp phpmailer drupal-6


    【解决方案1】:

    最终结果是 smtp.com 阻止了我们的 IP 地址。

    (几天前我曾问过他们这件事,他们否认了,但今天他们意识到他们是。)

    【讨论】:

      猜你喜欢
      • 2015-09-06
      • 2020-11-25
      • 2019-01-19
      • 2023-03-20
      • 2017-07-19
      • 2017-10-05
      • 2015-11-20
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多