简体   繁体   English

ActionMailer未在开发中发送邮件

[英]ActionMailer not sending mail in development

I have the following in my config/environments/development.rb 我在config / environments / development.rb中有以下内容

  # ActionMailer settings
  config.action_mailer.perform_deliveries = true
  config.action_mailer.raise_delivery_errors = true
  config.action_mailer.delivery_method = :smtp
  config.action_mailer.smtp_settings = {
    address: 'smtp.gmail.com',
    port: 587,
    domain: 'gmail.com',
    user_name: 'gmail account',
    password: 'password',
    authentication: 'plain',
    enable_starttls_auto: true}

I have the following Mailer and method to test sending an email 我有以下Mailer和方法来测试发送电子邮件

class EventMailer < ActionMailer::Base
  default from: "exmaple@gmail.com"

  def test_email
    mail(to: "Me <myemail@mail.com", subject: 'Test email')
  end

end

And inside one of my controller methods I have 在我的一个控制器方法中,我有

EventMailer.test_email().deliver

I can see in my terminal the message says it's been sent (I believe this is the log?), but I don't receive any actual email. 我可以在终端中看到消息说已经发送了(我相信这是日志吗?),但是我没有收到任何实际的电子邮件。 I'm new to the ActionMailer and was just following the steps on the ruby guides site but it doesn't work. 我是ActionMailer的新手,只是按照红宝石指南网站上的步骤操作,但它不起作用。 Not sure what I'm leaving out. 不知道我要离开的是什么。 No errors show up in my terminal when I try it out and I know my smtp_settings are correct because I can send emails using rubys Net::SMTP in my ruby interpreter using the same smtp settings as above. 我尝试时没有错误显示在我的终端中,我知道我的smtp_settings是正确的,因为我可以使用rubys Net :: SMTP在我的ruby解释器中使用与上面相同的smtp设置发送电子邮件。 I'm just having trouble getting it to work with ActionMailer. 我只是无法使用ActionMailer。 Any help is appreciated! 任何帮助表示赞赏!

It was the silliest thing. 这是最愚蠢的事情。 I just had to restart my local server after I changed the development.rb file >.< gaah 更改development.rb文件>。<gaah之后,我只需要重新启动本地服务器即可。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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