greycode
greycode

Reputation: 113

SwiftMail SMTP Error

I am trying to use the standard Swiftmail SMTP connection for Mandrill, which is located here:

http://help.mandrill.com/entries/21746308-Sending-via-SMTP-in-various-programming-languages

I am getting a:

Fatal error: Uncaught exception 'Swift_TransportException' with message 'Connection could not be established with host smtp.mandrillapp.com [Connection refused #111]' in /home/content/15/10121515/html/includes/classes/Swift/Transport/StreamBuffer.php:259 Stack trace: #0 /home/content/15/10121515/html/includes/classes/Swift/Transport/StreamBuffer.php(64): Swift_Transport_StreamBuffer->_establishSocketConnection() #1 /home/content/15/10121515/html/includes/classes/Swift/Transport/AbstractSmtpTransport.php(115): Swift_Transport_StreamBuffer->initialize(Array) #2 /home/content/15/10121515/html/includes/classes/Swift/Mailer.php(80): Swift_Transport_AbstractSmtpTransport->start() #3 /home/content/15/10121515/html/includes/mail.php(62): Swift_Mailer->send(Object(Swift_Message), Array) #4 {main} thrown in /home/content/15/10121515/html/includes/classes/Swift/Transport/StreamBuffer.php on line 259

Any ideas why?

Upvotes: 2

Views: 7746

Answers (6)

Wasim Khan
Wasim Khan

Reputation: 1237

For godaddy shared server, it works for me.

'driver' => 'smtp',
'host' => 'localhost',
'port' => '587',
'from' => array('address' => '[email protected]', 'name' =>'This is a Sign up mail' ),
'encryption' => 'tls',
'username' => 'xxxxxxxx',
'password' => 'xxxxxx',
'sendmail' => '/usr/sbin/sendmail -bs',
'pretend' => false,

Upvotes: 0

Salvador Dali
Salvador Dali

Reputation: 222531

I got the same problem today. Found this question, but due to the lack of answer I am writing how I was able to fix it (I assume that you are under Linux, as I am).

Apparently the problem is that there is no mail server installed. So you have to find the server of your choice and to install it. I used postfix and installed it in the following way:

sudo apt-get install postfix

This solved the problem.

Upvotes: 0

Eric W
Eric W

Reputation: 31

Don't waste your time and try to configure other SMTP servers (Gmail, mandrillapp etc) to handle your outgoing emails on a shared server. GoDaddy, Hostgator, etc... have blocked this option. I found that leaving "localhost" as the host and getting rid of the username and password worked like a charm! Seems too simple but it's true.

Upvotes: 2

Most likely, your credentials are wrong. Please recheck your API key as password and make sure that you use the right port to access smtp server.

Also, if you are using swiftmailer in Symfony2, make sure that you provide the default settings as below:

In app/config.yml:

# Swiftmailer Configuration
swiftmailer:
    transport: "%mailer_transport%"
    host:      "%mailer_host%"
    username:  "%mailer_user%"
    password:  "%mailer_password%"
    port:      "%mailer_port%"
    #spool:     { type: memory }

In addition, provide values for the configuration in your parameters/_dev.yml:

mailer_transport: smtp
mailer_host: smtp.mandrillapp.com
mailer_user: [USERNAME]
mailer_password: [APIKEY]
mailer_port: 587

Upvotes: 1

user2287474
user2287474

Reputation: 646

Had the same problem, I generated a new API key and it worked fine with that.

Upvotes: 0

Kaitlin
Kaitlin

Reputation: 6235

This indicates that you're not connecting to the Mandrill server, and usually means that the hosting provider is blocking outbound SMTP access, or the port that you're using. You can try switching ports (Mandrill supports 25, 587 and 2525 with no encryption or STARTTLS, and port 465 with SSL) or contacting the hosting provider to see if they can open the port you're using for access to Mandrill.

Upvotes: 4

Related Questions