如何发送本地主机电子邮件并使用Thunderbird进行捕获?
问题描述:
我试图从rails发送邮件并使用thunderbird捕获它。如何发送本地主机电子邮件并使用Thunderbird进行捕获?
这是我的邮件:
def hello_world
from = '[email protected]'
subject = 'Hello World'
to = '[email protected]'
main to: to, from: from, subject: subject
end
我跟着这个指令在本地配置的Thunderbird,它是工作的罚款。 https://gist.github.com/raelgc/6031274
我不知道如何配置rails。
我应该在development.rb中放置什么?
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:address => "localhost",
:port => 25,
:domain => "localhost"
}
答
试试这个
mail(to: to, from: from, subject: subject)
答
正如@ aniket饶建议:使用Mailcatcher这做这一切。不需要安装本地postfix服务器和提供收件箱。从文档:
MailCatcher运行一个超级简单的SMTP服务器,捕获发送到它的任何消息显示在Web界面。运行mailcatcher,将您最喜爱的应用程序设置为smtp://127.0.0.1:1025而不是默认的SMTP服务器,然后检查http://127.0.0.1:1080以查看迄今为止已到达的邮件。
在你的Rails环境中使用此配置发送电子邮件至Mailcatcher:
# use Mailcatcher
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = { address: 'localhost', port: 1025 }
您的邮箱将在端口上运行的本地Web应用程序可见1080
是的,你应该把它放在development.rb虽然它必须是雷鸟?试试这个https://mailcatcher.me/ –