2017-10-15 51 views
0

我試圖從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" 
    } 
+0

是的,你應該把它放在development.rb雖然它必須是雷鳥?試試這個https://mailcatcher.me/ –

回答

0

試試這個

mail(to: to, from: from, subject: subject) 
0

正如@ 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

相關問題