config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:address => "smtp.gmail.com",
:port => "587",
:domain => "gmail.com",
:authentication => "plain",
:user_name => "myusername@gmail.com",
:password => "mypassword",
:enable_starttls_auto => true
}
class UserMailer < ActionMailer::Base
default from: "myusername@gmail.com"
def confirm(email)
@message = "Thank you for confirmation!"
mail(:to => email, :subject => "Registered")
end
end
我输入UserMailer.confirm(“someone@example.org”)。在rails控制台中交付并发送出去。但我无法从目标邮箱收到任何邮件.... 设置中的Google帐户是我的个人google帐户,我使用相同的用户名和密码。