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

I am having trouble sending mail with xampp localhost using gmail. And after a long time, I finally succeeded. And I share it with all of you. If I am wrong, this requires the right solution.

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 .yml options

mailer_transport: smtp
mailer_host: smtp.gmail.com
mailer_user: gmail_user_id_without_@gmail.com
mailer_password: Your_gmail_pass
mailer_port: 465 or 587
mailer_encryption:  ssl 
+4
source share
2 answers

u can try this

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:  'Yourmail@gmail.com'
   password:  'Password'
+5
source

You can specify the parameters directly in the Swift configuration of the mail program or read them from the .ini parameters.

Example:

In the .ini options

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:  user@xyz.com
    password:  password
    spool:
      type: file
      path: "%kernel.root_dir%/extras/spool"

"" - , .

0

All Articles