-
-
Save nisanthchunduru/d341ab22dede19e572d0e8152393e93a to your computer and use it in GitHub Desktop.
send email to gmail (STARTTLS) using ruby >=1.8.7
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# send email using STARTTLS; Net::SMTP#enable_starttls requires ruby >=1.8.7 | |
# this hack is needed for rails <2.3; apparently >=2.3 has something for this already | |
ActionMailer::Base.class_eval do | |
private | |
def perform_delivery_smtp(mail) | |
destinations = mail.destinations | |
mail.ready_to_send | |
smtp = Net::SMTP.new(smtp_settings[:address], smtp_settings[:port]) | |
smtp.enable_starttls | |
smtp.start(smtp_settings[:domain], | |
smtp_settings[:user_name], | |
smtp_settings[:password], | |
smtp_settings[:authentication]) do |smtp| | |
smtp.sendmail(mail.encoded, mail.from, destinations) | |
end | |
end | |
end | |
ActionMailer::Base.smtp_settings = { | |
:address => "smtp.gmail.com", | |
:port => 587, | |
:user_name => '[email protected]', | |
:password => 'secret', | |
:authentication => :plain, | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment