作者:翟峰 | 来源:互联网 | 2023-09-13 14:05
IsthereareasonwhySwiftMailAPIforPHPwontrunonHostGator?Theirtechsupportsaidusethe
Is there a reason why SwiftMail API for PHP won't run on HostGator? Their tech support said use the mail() command and that socket connections to port 25 won't work like that on their shared hosting plan. I complained and said that when you google on how to send attachments with mail(), people tell you to use SwiftMail. I need to send file attachments with the email.
为什么PHP的SwiftMail API不能在HostGator上运行?他们的技术支持说使用mail()命令和套接字连接到端口25在他们的共享主机计划中不会像那样工作。我抱怨说,当你谷歌讨论如何用mail()发送附件时,人们会告诉你使用SwiftMail。我需要随邮件发送文件附件。
My code works just fine on A2Hosting, but not HostGator. In the API, I'm sending to localhost on port 25, using no authentication, using no SSL, and using a valid email address that does exist on this host (pretend it's example.com) -- noreply@example.com.
我的代码在a2host上工作得很好,但是在HostGator上不行。在API中,我在端口25上发送到localhost,不使用身份验证,不使用SSL,使用这个主机上存在的有效电子邮件地址(假设它是example.com)——noreply@example.com。
The error I'm getting is:
我得到的错误是:
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
If you've gotten SwiftMail API to work on HostGator, please share what you did.
如果您已经获得SwiftMail API来处理HostGator,请分享您所做的。
6 个解决方案