インストール
gem install mail
メール送信プログラム
require 'mail'
Mail.defaults do
delivery_method :smtp, {
:address => "mail.example.com", # smtpサーバのアドレス
:port => 587, # smtpサーバのポート
:user_name => "username", # smtpサーバへのユーザ名
:password => "password", # smtpサーバへのパスワード
:authentication => :plain # plainテキスト
}
end
mail = Mail.new do
from 'mail_from@example.com' # Fromアドレス
to 'mail_to@example.com' # Toアドレス
cc 'mail_cc@example.com' # CCアドレス
subject 'sample subject' # 題名
body 'sample message' # 本文
end
# メール送信
mail.deliver!
0 件のコメント:
コメントを投稿