Created
March 20, 2013 07:12
-
-
Save toshiharu/5202860 to your computer and use it in GitHub Desktop.
Ruby 1.9/2.0 で Gmail へメールを送る。Ruby 1.8 で必要だった tlsmail.rb はいらないことを知った。
This file contains 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
#!/usr/bin/ruby | |
# -*- coding: utf-8 -*- | |
require 'rubygems' | |
require 'net/smtp' | |
from_addr = 'from@example.com' | |
to_addr = 'to@example.com' | |
message = <<EOM | |
From: #{from_addr} | |
To: #{to_addr} | |
Subject: test | |
test | |
EOM | |
smtpserver = Net::SMTP.new('smtp.gmail.com', 587) | |
smtpserver.enable_starttls | |
smtpserver.start('localhost.localdomain', ユーザ名, パスワード, :plain) { |smtp| | |
smtp.send_message message, from_addr, to_addr | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment