【发布时间】:2014-07-15 15:09:56
【问题描述】:
我正在尝试使用经典的 PHP 脚本发送邮件。 邮件()版本:
<?php
ini_set('SMTP', 'srv-****.fr');
ini_set('smtp_port', '25');
$to = 'adrien.debono-ext@fake.fr';
$subject = 'TestMail PHP';
$message = 'Hello just testing please ignore';
$headers = 'From: dsi.fake@fake.fr' . "\r\n" .
'Reply-To: adrien.debono@fake.fr' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
echo('OK');
?>
Swift Mailer 版本
<?php
// Test mail with swift
require_once 'swiftmailer-master/lib/swift_required.php';
// Create the Transport
$transport = Swift_SmtpTransport::newInstance('srv-****.fr', 25);
$mailer = Swift_Mailer::newInstance($transport);
// Create a message
$message = Swift_Message::newInstance('Test Swift')
->setFrom(array('fake@fake.fr'))
->setTo('fake@hotmail.fr')
->setBody(' Test, please ignore')
;
// Send the message
$result = $mailer->send($message);
echo('Test.');
?>
当我使用一个简单的 mail() 函数时,我的页面加载了 2 分钟。然后邮件需要另外 2 分钟才能弹出我的收件箱。太长了。
当我尝试使用 30 秒后超时的 SwiftMailer 时,我收到此错误:
Fatal error: Uncaught exception 'Swift_TransportException' with message 'Connection to srv-exchange.mpm.fr:25 Timed Out' in C:\wamp\www\tests\swiftmailer-master\lib\classes\Swift\Transport\AbstractSmtpTransport.php on line 407
( ! ) Swift_TransportException: Connection to srv-*****.fr:25 Timed Out in C:\wamp\www\tests\swiftmailer-master\lib\classes\Swift\Transport\AbstractSmtpTransport.php on line 407
Call Stack
# Time Memory Function Location
1 0.0010 241416 {main}( ) ..\mailSwift.php:0
2 0.0520 2737536 Swift_Mailer->send( ) ..\mailSwift.php:19
3 0.0520 2737960 Swift_Transport_AbstractSmtpTransport->start( ) ..\Mailer.php:80
4 0.0620 2754568 Swift_Transport_AbstractSmtpTransport->_readGreeting( ) ..\AbstractSmtpTransport.php:119
5 0.0620 2754736 Swift_Transport_AbstractSmtpTransport->_getFullResponse( ) ..\AbstractSmtpTransport.php:291
6 30.0660 2804816 Swift_Transport_AbstractSmtpTransport->_throwException( ) ..\AbstractSmtpTransport.php:409
这是什么意思? 我该如何解决?
设置:在我的本地平台上使用 WAMP 服务器,该平台位于社会网络中。 我正在使用我社团的 SMTP 服务器。
今天测试后编辑: 我打电话给 IT 人员,我认为问题出在我的 WAMP 配置上。 一旦我找到了我的东西出了什么问题,我会回到这篇文章。
IT 人员看到了日志: 14h50 : 从我的 IP 地址传入连接 -- 3min30 什么都没有 14H54 消息已送达。
他向我保证没有群发邮件保护措施。我的 telnet 工作正常。我认为问题来自 WAMP。
【问题讨论】:
-
* 提及
mail函数。不显示 sn-p。 -
看起来您的公共 SMTP 服务器已设置 2 分钟间隔以防止群发邮件。
-
@GolezTrol 添加了缺失的片段,谢谢。
-
谢谢,但我认为@mudasobwa 对群发邮件保护的评论一针见血。
标签: php email wamp swiftmailer