1

I'm trying to send a simple email using my Gmail account through ruby's mail gem but the email is never sent nor received. I followed the steps from a similar question but I wasn't sure what to put under the domain field. I believe this may be my issue but I'm not sure.

my code:

require 'mail'

options = { :address              => "smtp.gmail.com",
            :port                 => 587,
            :domain               => 'your.host.name',
            :user_name            => 'REMOVED',
            :password             => 'REMOVED',
            :authentication       => 'plain',
            :enable_starttls_auto => true  }

Mail.defaults do
    delivery_method :smtp, options
end

mail = Mail.new do
    from    'REMOVED'
    to      'REMOVED'
    subject 'This is a test email'
    body    'test'
end
Community
  • 1
  • 1
adunn
  • 81
  • 1
  • 6

1 Answers1

0

I don't see where you are calling the deliver method to send the email. Based on the documentation, there's a couple of ways to do that:

Mail.deliver do
 from     'me@test.lindsaar.net'
 to       'you@test.lindsaar.net'
 ...
end

or

mail = Mail.new do
  from     'me@test.lindsaar.net'
  to       'you@test.lindsaar.net'
  ...
end

mail.deliver!
orde
  • 5,233
  • 6
  • 31
  • 33