Php 发送电子邮件symfony swiftmailer
我正试图通过swiftmailer和gmail发送电子邮件 我已在config.yml中输入:Php 发送电子邮件symfony swiftmailer,php,symfony,swiftmailer,Php,Symfony,Swiftmailer,我正试图通过swiftmailer和gmail发送电子邮件 我已在config.yml中输入: swiftmailer: transport: gmail username: xxx@gmail.com password: xxx 如果我在im localhost中使用它,把它们放在im config_dev.yml中,它工作得很好,如果我在im localhost中使用它,但是在prod版本中它工作得很好,但是如果我在服务器中使用我的prod版本,它就不工作了 有
swiftmailer:
transport: gmail
username: xxx@gmail.com
password: xxx
如果我在im localhost中使用它,把它们放在im config_dev.yml中,它工作得很好,如果我在im localhost中使用它,但是在prod版本中它工作得很好,但是如果我在服务器中使用我的prod版本,它就不工作了
有人知道为什么
蒂纳克斯
致以最诚挚的问候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帐户(),并在parameters.yml中使用您的mandrill smtp设置,然后检查该设置是否有效。您可能有一个主机,如果您想在主机中发送电子邮件,您可以使用php函数mail()执行此操作:
这与mandrill相同,im localhost它可以工作,但不是im server!当您说它在localhost中工作时,您是否在url中使用/app_dev.php?它在localhost中使用app_dev和app,但在服务器中使用app.php不工作,那么它可能是您的服务器?你用的是什么服务器?检查正在使用的smtp端口,确保它没有被阻止。是的,这是可能的,但我不知道如何检查。我做的更简单。只需使用邮件传输系统。
$to = 'email@domain.com';
$subject = 'subject';
$msg = 'Hi';
$others = 'From: contact@domain.com' ."\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $msg, $others);