PHP 版 SwiftMail API 无法在 HostGator 上运行是否有原因?他们的技术支持人员表示,使用 mail() 命令,到端口 25 的套接字连接将无法像他们的共享托管计划那样工作。我抱怨说,当你在谷歌上搜索如何使用 mail() 发送附件时,人们告诉你使用 SwiftMail。我需要通过电子邮件发送文件附件。
我的代码在 A2Hosting 上运行良好,但在 HostGator 上运行不正常。在 API 中,我在端口 25 上发送到本地主机,不使用身份验证,不使用 SSL,并使用该主机上确实存在的有效电子邮件地址(假设它是 example.com)--[电子邮件受保护] /cdn-cgi/l/email-protection.
我收到的错误是:
Warning: fsockopen() [function.fsockopen]: unable to connect to localhost:25 (Connection refused) in /home/user/public_html/mywebsite/addons/swiftmail-4.0.3/lib/classes/Swift/Transport/StreamBuffer.php on line 243
Fatal error: Uncaught exception 'Swift_TransportException' with message 'Connection could not be established with host localhost [Connection refused #111]' in /home/user/public_html/mywebsite/addons/swiftmail-4.0.3/lib/classes/Swift/Transport/StreamBuffer.php:245 Stack trace: #0 /home/user/public_html/mywebsite/addons/swiftmail-4.0.3/lib/classes/Swift/Transport/StreamBuffer.php(80): Swift_Transport_StreamBuffer->_establishSocketConnection() #1 /home/user/public_html/mywebsite/addons/swiftmail-4.0.3/lib/classes/Swift/Transport/AbstractSmtpTransport.php(111): Swift_Transport_StreamBuffer->initialize(Array) #2 /home/user/public_html/mywebsite/addons/swiftmail-4.0.3/lib/classes/Swift/Mailer.php(84): Swift_Transport_AbstractSmtpTransport->start() #3 /home/user/public_html/mywebsite/mailer.php(34): Swift_Mailer->send(Object(Swift_Message)) #4 /home/user/public_html/mywebsite/mailer.php(146): Mailer->sendMail() #5 {main} thrown in /home/user/public_html/mywebsite/addons/swiftmail-4.0.3/lib/classes/Swift/Transport/StreamBuffer.php on line 245
如果您已经让 SwiftMail API 在 HostGator 上运行,请分享您所做的事情。
您可以尝试使用Swift_MailTransport
代替Swift_SmtpTransport
这将使用本机mail()
调用幕后。
我没有使用 HostGator 的经验,但如果他们的支持人员表示系统允许发送mail()
这应该可以正常工作。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)