在 Rails 中发送电子邮件

发布于 2024-11-29 07:49:20 字数 611 浏览 2 评论 0原文

我尝试使用 Ruby on Rails 发送电子邮件,但收到错误:

UsersController#create 中的 Net::SMTPAuthenticationError

535-5.7.1 用户名和密码不被接受。


但用户名和密码组合是正确的。我已经经历过很多次了。

这是我的 setup_mail.rb:
出于隐私原因,我更改了用户名、密码和域名。

ActionMailer::Base.smtp_settings = { 
    :address            => "smtp.gmail.com",
    :port               => 587,
    :domain             => "mydomain.com",
    :authentication     => "plain",
    :user_name          => "myname",
    :password           => "mypw",
    :enable_starttls_auto   => true
}

I'm trying to send an email using Ruby on Rails but I get the error:

Net::SMTPAuthenticationError in UsersController#create

535-5.7.1 Username and Password not accepted.


But the username and password combination is correct. I've gone through it multiple times.

This is my setup_mail.rb:
I changed the username, password and domain for privacy reasons.

ActionMailer::Base.smtp_settings = { 
    :address            => "smtp.gmail.com",
    :port               => 587,
    :domain             => "mydomain.com",
    :authentication     => "plain",
    :user_name          => "myname",
    :password           => "mypw",
    :enable_starttls_auto   => true
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文