问题
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: gmail_user_id_without_@gmail.com
mailer_password: Your_gmail_pass
mailer_port: 465 or 587
mailer_encryption: ssl
回答1:
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: 'Yourmail@gmail.com'
password: 'Password'
回答2:
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: user@xyz.com
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.
来源:https://stackoverflow.com/questions/19086476/send-mail-through-smtp-gmail-com-in-symfony-2-using-swiftmailer