Can't get SMTP to work (connection could not be established with host localhost)

Asked by Nick Pateman

Hi there,

I have been following this article to configure the SMTP server,

http://www.metulo.net/how-to-send-an-email-with-symfony-and-gmail

Everything is setup so I try to navigate to the login page,

http://myserver/login

The page appears fine and I click the link to register a new account. I fill in the details and click next, I get a server 500 error in response.

In the error log I can see the error "connection could not be established with host localhost". My SMTP server isn't set to local host, it's a fully working domain name, where is it getting localhost from and how comes it isn't picking up my settings?

I've set the server details in

/var/www/authpuppy/apps/frontend/config/factories.yml

Question information

Language:
English Edit question
Status:
Solved
For:
AuthPuppy Edit question
Assignee:
No assignee Edit question
Solved by:
Nick Pateman
Solved:
Last query:
Last reply:
Revision history for this message
Nick Pateman (3-nick-2) said :
#1

I've also tried editing the file

/var/www/authpuppy/lib/vendor/symfony/lib/config/config/factories.yml

This has an email section with localhost configured so I thought that might be it, but it did not work and the same error persists.

Revision history for this message
Nick Pateman (3-nick-2) said :
#2

After a hell of a lot of trial and error I have solved my issue, albeit not to a production level of quality. In order to continue and receive the email and create the account, I have modified the php file with

sudo nano /var/www/authpuppy/cache/frontend/prod/config/config_factories.yml.php

Right near the bottom is a call to a method "setMailerConfiguration", I'm assuming one parameter is the configuration file and another is the default parameters, it seems to be using default parameters all the time so I'm going to try and find out why. But setting these default settings to my actual SMTP detais got it working.

Revision history for this message
Nick Pateman (3-nick-2) said :
#3

I'm just sticking with modifying the source code for now.

It's a shame there's no one actively helping in this forum, kind of pointless it existing really.

Revision history for this message
Bao Linh (d-aqmin-s) said :
#4

you should edit
/var/www/authpuppy/lib/vendor/symfony/lib/config/config/factories.yml
after that delete file
/var/www/authpuppy/cache/frontend/prod/config/config_factories.yml.php
in cache folder , config it very easy for gmail
  mailer:
    class: sfMailer
    param:
      logging: %SF_LOGGING_ENABLED%
      charset: %SF_CHARSET%
      delivery_strategy: realtime
      transport:
        class: Swift_SmtpTransport
        param:
          host: smtp.gmail.com
          port: 465
          encryption: ssl
          username: <email address hidden>
          password: pass