【发布时间】:2014-06-02 03:16:26
【问题描述】:
我一直在尝试使用 PHP 的 SwiftMailer 库来发送电子邮件。它在开发过程中运行良好。但是,在实际使用时,它似乎只发送到特定域。例如,如果我有 domain.com 和 another_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