Running environment:
Ruby 1.8.6
Rails 1.2.5
Gem 1.0.1
The gmail server is used here. Because actionMailer in rails does not support TLS (SSL) connections, it is the only transmission method on the Gmail SMTP server. There is a plug-in provided for this problem on the Internet. The following describes the specific configuration steps:
1. Install the plug-in: Open cmd and enter the directory of the rails project.
Input ruby script/plugin install http://svn.xlsuite.org/trunk/vendor/plugins/action_mailer_tls/
Find "smtp_tls.rb" in the project directory and put it in the lib directory of the project.
2. Configure the environment of the rails project:
Open the config/environment. rb file of the project:
Add: require 'smtp _ tls '# reference libsmtp_tls.rb
ActionMailer: Base. delivery_method =: smtp # Use smtp to send emails
ActionMailer: Base. default_charset = "UTF-8" # specifies the character set used to send the mail
ActionMailer: Base. server_settings = {
: Address => "smtp.gmail.com", # The email server used.
: Port => 587, # the port number of the email server
: Domain => "xxx.com", # Temporarily ignore
: Authentication =>: Login, # not very clear, write as follows
: User_name => "yourname@gmail.com", # Use the mail server account (here is Google, so it is the Goole mailbox account)
: Password => "yourpassword", # Use the password of the email server
# Note: I only specified the email server here. It does not mean that if I specified the Google email server, I had to use Google's email to send emails, or use another email address to send emails through Google's email server.
}
3. Restart the Project server
If your rails version is newer:
Add the following configuration information between the environment. rb file Rails: Initializer. run do | config | and end:
# Config/environments/development. rb
Config. action_mailer.raise_delivery_errors = true # An error is thrown to the application.
# Set delivery method to: smtp,: sendmail or: test
Config. action_mailer.delivery_method =: smtp # mail sending Method
# These options are only needed if you choose SMTP delivery
Config. action_mailer.smtp_settings = {
: Address => 'smtp .gmail.com ',
: Port => 587,
: Authentication =>: Plain,
: User_name => 'yourname @ gmail.com ', # your Gmail account
: Password => 'yourpassword' # your Gmail Password
}