PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Mon Nov 24, 2014 7:05 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Wed Aug 24, 2011 12:08 am 
Offline
Forum Regular
User avatar

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


Top
 Profile  
 
PostPosted: Wed Aug 24, 2011 12:28 am 
Offline
Forum Regular
User avatar

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


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group