2008-12-24 28 views

回答

4

我這樣做有ssmtp中。它充當SMTP服務器並代理真正的SMTP服務器。在Unix上(在這種情況下Ubuntu耐用),它使系統sendmail正常工作。

如果您還在使用Ubuntu,請運行apt-get install ssmtp以獲取它。

這是一個基於我的示例配置文件。

# 
# Config file for sSMTP sendmail 
# 
# The person who gets all mail for userids < 1000 
# Make this empty to disable rewriting. 
root=postmaster 

# The place where the mail goes. The actual machine name is required no 
# MX records are consulted. Commonly mailhosts are named mail.domain.com 
#mailhub=aspmx.l.google.com 
mailhub=smtp.gmail.com:587 

# Where will the mail seem to come from? 
rewriteDomain=example.com 

# The full hostname 
hostname=yourhostname.example.com 

# Are users allowed to set their own From: address? 
# YES - Allow the user to specify their own From: address 
# NO - Use the system generated From: address 
FromLineOverride=YES 

# should turn on SSL & auth to google's SMTP server 
# TODO change this user 
UseTLS=YES 
UseSTARTTLS=YES 
[email protected] 
AuthPass=yourgooglepassword 

你會想要將它添加到您的environment.rbproduction/environment.rb

ActionMailer::Base.delivery_method = :sendmail 
ActionMailer::Base.raise_delivery_errors = true 
+1

我嘗試這一點,但我得到了以下錯誤:在UsersController# 變量Errno :: EPIPE創建 管道中斷 我測試了sendmail和ssmtp,並可以通過軌道外的終端發送電子郵件到地址。你有沒有洞察什麼可能導致這個或它的意思?谷歌搜索沒有成功的解決方案。 – zalberico 2011-12-03 02:45:59