What's with HostGator shared hosting and SwiftMailer?

Swift Mailer is a fantastic library for sending email with php. Discuss this library or ask any questions about it here.

Moderators: Chris Corbyn, General Moderators

What's with HostGator shared hosting and SwiftMailer?

Postby volomike » Wed Aug 24, 2011 12:08 am

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
User avatar
volomike
Forum Regular
 
Posts: 632
Joined: Wed Jan 16, 2008 10:04 am
Location: Myrtle Beach, South Carolina, USA

[SOLVED] What's with HostGator shared hosting and SwiftMaile

Postby volomike » Wed Aug 24, 2011 12:28 am

Did some tests and found the answer:

http://stackoverflow.com/questions/7170 ... 29#7170829

In short, don't use 'localhost', but use the domain name your project is in.
User avatar
volomike
Forum Regular
 
Posts: 632
Joined: Wed Jan 16, 2008 10:04 am
Location: Myrtle Beach, South Carolina, USA


Return to Swift Mailer

Who is online

Users browsing this forum: No registered users and 2 guests