简体   繁体   中英

send email symfony swiftmailer

I'm trying to send an email via swiftmailer and gmail.

I have put in my config.yml:

swiftmailer:
    transport: gmail
    username:  xxx@gmail.com
    password:  xxx

If I use it im localhost, putting them im config_dev.yml, it work fine, if I use it im localhost but with the prod version it work fine, but if I use my prod version in the server it doesn't work.

Somebody knows why?

Thnaks Best regards

Are the right parameters set in parameters.yml? like so:

# app/config/parameters.yml
parameters:
    # ...
    mailer_transport: gmail
    mailer_host:      ~
    mailer_user:      your_gmail_username
    mailer_password:  your_gmail_password

Also, you could try to intercept emails (i think ths can only be done in development) and see whats happening when you try to send mail:

# app/config/config_dev.yml
web_profiler:
    intercept_redirects: true

You could also try signing up to a free mandrill account ( https://mandrill.com/ ) and using your mandrill smtp settings in parameters.yml and check if that works instead.

Is possible that You have a hosting, if You want send emails in hosting You can do it with php function mail():

$to      = 'email@domain.com';
$subject   = 'subject';
$msg       = 'Hi';
$others     = 'From: contact@domain.com' ."\r\n" .
'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $msg, $others);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM