0

I am trying to send email with my Symfony Application. My goal is to send the emails either with a gmail account or from the server's email account.

After some research I succed to send emails from my local server wamp. The configuration is the following :

swiftmailer:
  transport: %mailer_transport%
  encryption: %mailer_encryption%
  auth_mode: %mailer_auth_mode%
  host:      %mailer_host%
  username:  %mailer_user%
  password:  %mailer_password%
  spool:     { type: memory }

mailer_transport: smtp
mailer_encryption: ssl
mailer_auth_mode: login
mailer_host: smtp.gmail.com
mailer_transport: gmail
mailer_user: myaccount
mailer_password: mypassword

I tried this configuration on my OVH server but it doesn't work. I looked in the OVH server logs but didn't find any error message.

I also tried some configuration with my server email account from my local server WAMP without success.

Here is one example :

swiftmailer:
  transport: %mailer_transport%
  auth_mode: %mailer_auth_mode%
  host:      %mailer_host%
  port:      %mailer_port%
  username:  %mailer_user%
  password:  %mailer_password%
  spool:     { type: memory }

mailer_transport: smtp
mailer_auth_mode: login
mailer_host: smtp.mydomain.be  
mailer_port: 587  
mailer_user: admin@mydomain.be  
mailer_password: mypassword2

1 Answers1

1

The solution is to set your mailer_transport parameter to 'mail' so SwiftMailer will use the default PHP mail() function.

Otherwise, you could specify the transport directly from your controller:

    // Mail() transport
    $transport = \Swift_MailTransport::newInstance();

    // Message
    $message = \Swift_Message::newInstance()
            ->setFrom("me@domain.org", "My Name")
            ->setTo(array(
                "user@domain.org" => "User Name"
            ))
            ->setSubject("Solution for sending e-mail from OVH")
            ->setBody("...", 'text/plain')
    ;

    // My instance of mailer
    $mailer = \Swift_Mailer::newInstance($transport)
            ->send($message);

Worked for me on an OVH plan with shared e-mail.

Anna Logg
  • 39
  • 1