PHP Developers Network

What's with HostGator shared hosting and SwiftMailer?
Page 1 of 1

Author:  volomike [ Wed Aug 24, 2011 12:08 am ]
Post subject:  What's with HostGator shared hosting and SwiftMailer?

My client has HostGator shared hosting. I've been using SwiftMailer API for some time now with a2hosting and other cPanel-based hosts, but never have I encountered the likes of HostGator. On HostGator, they have some kind of funky deal where their Tech Support team told me I need to use the mail() command in PHP, not a socket connection! Trouble is -- when you google on "how to send file attachments with mail()", you get "use SwiftMailer API". I am shocked and appalled that HostGator is so behind the times here and doesn't have a shared hosting plan that seems to support SwiftMailer API. I mean, geeeeez, almost everyone uses SwiftMailer in PHP -- so why is HostGator so behind the times here? My code runs just fine on A2Hosting shared hosting, however, as it does on many other cPanel-based hosting plans.

I created a noreply@ account on the host, and then used the SwiftMailer API to try to send the email (with attachment) to the end user. I'm sending via port 25 to localhost with no username or password. I'm not using SSL connections for the mail. Here's the error I'm getting.

Have you ever gotten SwiftMailer to work properly on HostGator? What did you do? Did you use a username and password? Did you use an alternative port? Did you, instead of using "localhost", use the domain? Did you use the root domain or did you use the addon domain? Note in my case I am working with an addon domain for this project.

Syntax: [ Download ] [ Hide ]
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

Author:  volomike [ Wed Aug 24, 2011 12:28 am ]
Post subject:  [SOLVED] What's with HostGator shared hosting and SwiftMaile

Did some tests and found the answer: ... 29#7170829

In short, don't use 'localhost', but use the domain name your project is in.

Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB® Forum Software © phpBB Group