[英]send email symfony swiftmailer
我正在尝试通过swiftmailer和gmail发送电子邮件。
我已经输入了我的config.yml:
swiftmailer:
transport: gmail
username: xxx@gmail.com
password: xxx
如果我使用它im localhost,把它们im config_dev.yml,它工作正常,如果我使用它本地主机但使用prod版本它工作正常,但如果我在服务器中使用我的prod版本它不起作用。
有人知道为什么吗?
Thnaks最好的问候
在parameters.yml中设置了正确的参数吗? 像这样:
# app/config/parameters.yml
parameters:
# ...
mailer_transport: gmail
mailer_host: ~
mailer_user: your_gmail_username
mailer_password: your_gmail_password
此外,您可以尝试拦截电子邮件(我认为这只能在开发中完成)并查看当您尝试发送邮件时发生的事情:
# app/config/config_dev.yml
web_profiler:
intercept_redirects: true
您还可以尝试注册免费的mandrill帐户( https://mandrill.com/ )并使用parameters.yml中的mandrill smtp设置,并检查是否可行。
有可能你有托管,如果你想在托管中发送电子邮件你可以用PHP函数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);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.