【问题标题】:SwiftMailer not sending to other domainSwiftMailer 不发送到其他域
【发布时间】:2014-06-02 03:16:26
【问题描述】:

我一直在尝试使用 PHP 的 SwiftMailer 库来发送电子邮件。它在开发过程中运行良好。但是,在实际使用时,它似乎只发送到特定域。例如,如果我有 domain.comanother_domain.com 的用户并使用 SMTP 服务器 server.domain.com,则电子邮件仅由 domain.com 的用户接收。

但是没有错误。以下是日志:

<< server.domain.com Hello [10.xx.xx.xx], pleased to meet you
250-ENHANCEDSTATUSCODES
250-PIPELINING
250-8BITMIME
250-SIZE
250-DSN
250-ETRN
250-DELIVERBY
250 HELP

++ Swift_SmtpTransport started
>> MAIL FROM: <server.test@domain.com>

<< 250 2.1.0 <server.test@domain.com>... Sender ok

>> RCPT TO: <user@domain.com>

<< 250 2.1.5 <user@domain.com>... Recipient ok

>> DATA

<< 354 Enter mail, end with "." on a line by itself

>> 
.

<< 250 2.0.0 sxxxxxxxxxxxxx Message accepted for delivery

>> MAIL FROM: <server.test@domain.com>

<< 250 2.1.0 <server.test@domain.com>... Sender ok

!! Connection to server.domain.com:25 Timed Out
>> RSET

<< 250 2.1.5 <another_user@another_domain.com>... Recipient ok

下面是我使用的代码。

$message = Swift_Message::newInstance()
  ->setSubject($subject)
  ->setFrom(array($from))
  ->setTo($to)
  ->setBody($message, 'text/html');
if (isset($file)) $message = $message->attach(Swift_Attachment::fromPath($file));
$transport = Swift_SmtpTransport::newInstance($smtp_server, $smtp_port);
$mailer = Swift_Mailer::newInstance($transport);
return $mailer->send($message);

我必须对代码进行一些更正还是这是一个外部问题?

【问题讨论】:

  • 您确定它们正在被接收并且可能在垃圾邮件过滤器中吗?
  • 我向用户确认了,他们说,客户端没有垃圾邮件文件夹,所以我猜没有。

标签: php email swiftmailer


【解决方案1】:

由于某种原因,电子邮件发送到外部地址比发送到内部地址需要更长的时间。我似乎找不到 SwiftMailer 的超时选项,所以我改用 PHPMailer 库,因为它提供了 Timeout 选项。将 SMTP 服务器超时设置为更高的值可以解决此问题。

【讨论】:

    猜你喜欢
    • 2011-10-15
    • 1970-01-01
    • 2020-12-01
    • 2019-01-29
    • 2017-12-28
    • 2014-04-04
    • 1970-01-01
    • 2012-05-23
    • 2020-08-04
    相关资源
    最近更新 更多