HostGator不会通过PHP SwiftMail API发送邮件 [英] HostGator Won't Send Mail via PHP SwiftMail API

查看:148
本文介绍了HostGator不会通过PHP SwiftMail API发送邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么SwiftMail API for PHP不能在HostGator上运行?他们的技术支持表示使用mail()命令,并且该端口25的套接字连接将不会像共享托管计划那样工作。我抱怨说,当你google如何发送附件与邮件(),人们告诉你使用SwiftMail。 我需要通过电子邮件发送文件附件。



我的代码在A2Hosting上工作正常,但不是HostGator。在API中,我在25端口发送到localhost,不使用任何身份验证,不使用SSL,并使用该主机上存在的有效电子邮件地址(假装是example.com) - noreply@example.com。 / p>

我得到的错误是:

 警告:fsockopen )[function.fsockopen]:无法连接到localhost:25(连接拒绝)在/home/user/public_html/mywebsite/addons/swiftmail-4.0.3/lib/classes/Swift/Transport/StreamBuffer.php第243行

致命错误:在/home/user/public_html/mywebsite/addons/swiftmail-4.0中,无法与主机localhost [Connection refused#111]'建立消息'Connection无法建立异常'Swift_TransportException'。 3 / lib / classes / Swift / Transport / StreamBuffer.php:245堆栈跟踪:#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}抛在/home/user/public_html/mywebsite/addons/swiftmail-4.0.3/lib/classes /Swift/Transport/StreamBuffer.php在线245

如果您已经使用SwiftMail API HostGator请分享您所做的一切。

解决方案

您可以尝试使用 Swift_MailTransport 而不是 Swift_SmtpTransport ,它将使用本地 mail()在幕后调用。



我没有HostGator的经验,但如果他们的支持说系统允许通过 mail()发送,这应该可以正常运行。


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.

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.

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.

解决方案

You can try using Swift_MailTransport instead of Swift_SmtpTransport which will use the native mail() call behind the scenes.

I have no experience with HostGator but if their support says the system allows sending through mail() this should work fine.

这篇关于HostGator不会通过PHP SwiftMail API发送邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆