| Class | Mail::SMTP |
| In: |
lib/mail/network/delivery_methods/smtp.rb
|
| Parent: | Object |
Mail allows you to send emails using SMTP. This is done by wrapping Net::SMTP in an easy to use manner.
Sending locally (to a postfix or sendmail server running on localhost) requires no special setup. Just to Mail.deliver &block or message.deliver! and it will be sent in this method.
Mail.defaults do
delivery_method :smtp, { :address => "smtp.me.com",
:port => 587,
:domain => 'your.host.name',
:user_name => '<username>',
:password => '<password>',
:authentication => 'plain',
:enable_starttls_auto => true }
end
Mail.defaults do
delivery_method :smtp, { :address => "smtp.gmail.com",
:port => 587,
:domain => 'baci.lindsaar.net',
:user_name => '<username>',
:password => '<password>',
:authentication => 'plain',
:enable_starttls_auto => true }
end
Feel free to send me other examples that were tricky
Once you have the settings right, sending the email is done by:
Mail.deliver do
to 'mikel@test.lindsaar.net'
from 'ada@test.lindsaar.net'
subject 'testing sendmail'
body 'testing sendmail'
end
Or by calling deliver on a Mail message
mail = Mail.new do
to 'mikel@test.lindsaar.net'
from 'ada@test.lindsaar.net'
subject 'testing sendmail'
body 'testing sendmail'
end
mail.deliver!