ActionMailer クラスをテストしたいのですが、smtp サーバーがありません。そのようなメールを送信するためにgmailを使用したいと思います。Google とアプリ内の構成ファイルの両方で必要なすべての構成を含むサンプルを誰かが提供できますか?
3753 次
2 に答える
5
GMail では SSL SMTP しか利用できないため、Net::SMTP を介して SSL SMTP 接続を作成する必要があります。
この記事をチェックしてください:
于 2008-12-24T21:27:46.723 に答える
4
これは SSMTP で行います。SMTP サーバーとして機能し、実際の SMTP サーバーにプロキシします。Unix (この場合は Ubuntu hardy) では、システム 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
AuthUser=yourgoogleuser@example.com.com
AuthPass=yourgooglepassword
environment.rb
これをorに追加したいと思うでしょうproduction/environment.rb
:
ActionMailer::Base.delivery_method = :sendmail
ActionMailer::Base.raise_delivery_errors = true
于 2008-12-25T02:32:36.063 に答える