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

2

6

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 
Designate answered 30/9, 2013 at 4:28 Comment(3)
what you mean by And after a long time I finally successful on it. And I am sharing it with all you ?Theory
There is a cookbook entry for sending emails with swiftmailer via gmail: symfony.com/doc/current/cookbook/email/gmail.htmlSankaran
You succesfully did it??? With mailer_transport: smtp or mailer_transport: gmail ? I am really confused in this post, question and answer are misleading! please to provide with the exact info.Guileful
D
7

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'
Delicacy answered 30/9, 2013 at 10:6 Comment(1)
This worked for me perfectly for Symfony 3.2. Thank you!Paediatrician
B
0

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.

Burkle answered 30/9, 2013 at 9:17 Comment(1)
Unrecognized option "mailer_auth_mode" under "swiftmailer.mailers.default"Pyrite

© 2022 - 2024 — McMap. All rights reserved.