0

I have my website in production, with Hostinger, and with the same parameters and config I can't send emails in production but I could in developing mode. I have changed the parameters and config files with others settings I have seen in other questions but with no success. Anyway, the error I get is the following:

Connection could not be established with host smtp.gmail.com [Connection timed out #110] 500 Internal Server Error - Swift_TransportException

My parameters.yml file:

parameters:
    ...
    mailer_transport: gmail
    mailer_encryption: ssl
    mailer_auth_mode: login
    mailer_host: smtp.gmail.com
    mailer_user: xxxxx@gmail.com
    mailer_password: xxxx
    ...

My config.yml file:

# Swiftmailer Configuration
swiftmailer:
    transport: gmail
    host:      smtp.gmail.com
    username:  xxxxx@gmail.com
    password:  xxxx

My controller file:

public function kontaktuaAction()
{
    $kontaktua = new Kontaktua();
    $form = $this->createForm(new KontaktuaType(), $kontaktua);

    $request = $this->getRequest();
    if ($request->getMethod() == 'POST') {
        $form->bind($request);

        if ($form->isValid()) {

            $message = \Swift_Message::newInstance()
                ->setSubject($kontaktua->getGaia())
                ->setTo('xxxxx@gmail.com')
                ->setFrom($kontaktua->getEmaila())
                ->setBody($kontaktua->getIzena().'(e)k, email helbidea '.$kontaktua->getEmaila().' duena hurrengo mezu hau'.
                     ' bidali dizu: '.$kontaktua->getMezua());
            $this->get('mailer')->send($message);

            return $this->redirect($this->generateUrl('kontaktua'));
        }
    }

    return $this->render('TaldeaBundle:Default:kontaktua.html.twig', array(
        'form' => $form->createView()
    ));
}
xaaleja
  • 81
  • 1
  • 2
  • 12

1 Answers1

0

The following settings works for me:

config.yml under swiftmailer
     encryption: ssl
     auth_mode:  login  

parameters.yml:
  mailer_transport: smtp
  mailer_host: smtp.gmail.com
  mailer_user: #gmail_user_name
  mailer_password: #gmail_password
shacharsol
  • 2,326
  • 20
  • 14