HostGator will not send mail through the PHP SwiftMail API

Is there a reason why the SwiftMail API for PHP will not run on HostGator? Their tech support said it was using the mail () command, and that socket connections to port 25 would not work as they did in terms of co-location. I complained and said that when you send messages about how to send attachments using mail (), people tell you to use SwiftMail. I need to send file attachments by email.

My code works fine on A2Hosting but not HostGator. In the API, I send to localhost on port 25, without using authentication, using SSL, and using a valid email address that exists on this host (pretend it example.com) - noreply@example.com.

The error I get 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 got the SwiftMail API for working with HostGator, share what you did.

+5
source share
6 answers

You can try using Swift_MailTransportinstead Swift_SmtpTransport, which will use your own mail()call backstage.

HostGator, , mail(), .

+13

. , :

  • 25,
  • SSL/TLS
  • / ,
  • "localhost" - , , , ,
  • , . , example1.com , example2.com - . , noreply@example2.com cPanel, API SwiftMailer.
+4

, , CPanel, , - , , , MX .

, , , localhost exim mail server.

+2

, (, example.com) - noreply@example.com.

, ? mx- example.com

0

SwiftMail PHP hostgator Swift_SmtpTransport, gmail ssl. "Connection smtp.gmail.com [Connection failed # 111]". Swift_MailTransport , , hostgator; Google .

HostGator cPanel SMTP, .

0

I got this error while trying to send emails using Amazon Simple Mail Service. In the end, it turned out that my authority to use AmazonSES was wrong. As soon as I got it right, every thing resolved for me.

By the way, I used PHP Swift_SmtpTransport

0
source

All Articles