swiftmailer send email using gmail with custom domain
Asked Answered
D

2

4

In symfony2.3 I am using swiftmailer.

I have a Google Apps address like [email protected] and my normal gmail address [email protected]

When using:

mailer_transport:  smtp
mailer_encryption: ssl
auth_mode:         login
mailer_host:       smtp.gmail.com
mailer_user:       myname
mailer_password:   pymass

the configuration works great and it sends emails from my gmail address but using [email protected] as mailer_user with correct password doesn't work.

Any ideas?

Delbert answered 31/7, 2013 at 12:13 Comment(0)
F
7

The configuration for sending from (what I assume is) a Google Apps account differs from a Gmail account. Your swiftmailer parameters should look something like this:

mailer_transport:  smtp
mailer_host:       smtp.gmail.com
mailer_user:       [email protected]
mailer_password:   pymass
auth_mode:         login
port:              587
encryption:        tls

Make sure to include your entire email address as well as the port and encryption protocol.

I derived the solution from this article a few months back.

Also, a small note: its encryption not mailer_encyption. You can read more about the swiftmailer parameters for Symfony here.

Frederigo answered 31/7, 2013 at 13:3 Comment(0)
W
0

When you create the message in your controller or anywhere, it's there where you put the sender (setFrom method)

// Create a message
$message = Swift_Message::newInstance('Wonderful Subject')
  ->setFrom(array('[email protected]' => 'John Doe'))
  ->setTo(array('[email protected]', '[email protected]' => 'A name'))
  ->setBody('Here is the message itself')
;

In your configuration file the mailer_user is used only for connecting to the gmail's smtp server.

Warranty answered 31/7, 2013 at 12:34 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.