ex:
require 'rubygems'
require 'action_mailer'
require 'smtp_tls'
class Emailer <>
def test_email(email_address, email_body)
recipients(email_address)
from "peter@gmail.com"
subject "This is a test e-mail"
body email_body
end
end
ActionMailer::Base.smtp_settings = {
:address => "smtp.gmail.com",
#25 ,465
:port => 587,
#:domain => "localhost.localdomain",
:authentication => :plain,
:user_name => "peter",
:password => "xxxxxx",
}
Emailer.deliver_test_email('jack@yahoo.com', 'this is a test email')
smtp_tls is for sending email from gmail
send by gmail in rails:
1. add smtp_tls.rb in configure directory
2. add require 'smtp_tls' in environment.rb
沒有留言:
張貼留言