Using Ruby to send email through Gmail

This works:

require 'net/smtp'

    @msg = "Subject: Hello!\nThis works in Gmail"
    smtp = Net::SMTP.new 'smtp.gmail.com', 587
    smtp.enable_starttls
    smtp.start('localhost', YourAccountName, YourPassword, :login)
      smtp.send_message(@msg, FromAddress, ToAddress)
    smtp.finish
Advertisements

1 Comment »

  1. […] Ruby script to send an email Posted in Uncategorized by Scott on January 15, 2011 This works too: require […]

RSS feed for comments on this post · TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: