Al- Imran Khan
Al- Imran Khan

Reputation: 187

Send mail through smtp.gmail.com in symfony 2 using swiftmailer

I am having a trouble of sending mail from xampp localhost using gmail. And after a long time I finally successful on it. And I am sharing it with all you. If I am wrong need proper solution for it.

in config.yml of your symfony 2 Write those

swiftmailer:
    disable_delivery:  false
    transport: %mailer_transport%
    host:      %mailer_host%
    username:  %mailer_user%
    password:  %mailer_password%
    port:      %mailer_port%
    encryption: %mailer_encryption%

In your parameters.yml

mailer_transport: smtp
mailer_host: smtp.gmail.com
mailer_user: [email protected]
mailer_password: Your_gmail_pass
mailer_port: 465 or 587
mailer_encryption:  ssl 

Upvotes: 6

Views: 18703

Answers (2)

GOPI
GOPI

Reputation: 1060

u can try this one

Parameter.yml

mailer_transport: gmail
mailer_encryption: ssl
mailer_auth_mode: login
mailer_host: smtp.gmail.com
mailer_user: 'xxxxxxxxxxxx'

config.yml

swiftmailer:
   transport: gmail
   host:      smtp.gmail.com
   username:  '[email protected]'
   password:  'Password'

Upvotes: 7

Praveesh
Praveesh

Reputation: 1327

You can either specify the parameters directly in the Swift mailer cofiguration or read them from parameters.ini.

Example:

In parameters.ini

mailer_transport  = smtp
mailer_host       = localhost
mailer_user       = null    
mailer_password   = null

In config.yml,

# Swiftmailer Configuration
swiftmailer:
    transport: smtp
    encryption: ssl
    auth_mode: login
    host:      smtp.gmail.com
    username:  [email protected]
    password:  password
    spool:
      type: file
      path: "%kernel.root_dir%/extras/spool"

Here, 'path' is the path to the directory where the spooled mails are stored.

Upvotes: 0

Related Questions