Skip to content

Instantly share code, notes, and snippets.

@okochang
Created June 30, 2012 10:53
Show Gist options
  • Save okochang/3023363 to your computer and use it in GitHub Desktop.
Save okochang/3023363 to your computer and use it in GitHub Desktop.
send sesmail by smtp-interface
# -*- coding: utf-8 -*-
require 'time'
require 'net/smtp'
HOST = 'email-smtp.us-east-1.amazonaws.com'
PORT = 465
HELO = 'localhost'
ACCESS_KEY = 'YOUR_SMTP_USERNAME'
SECRET_KEY = 'YOUR_SMTP_PASSWORD'
FROM_ADDR = 'yanase@okochang.com'
TO_ADDR = 'user@example.com'
msg =<<EOF
From: yanase@okochang.com
To: user@example.com
Subject: testmail
Date: #{Time.now.rfc2822}
ses-test-mail
\r\n
EOF
smtp = Net::SMTP.new(HOST, PORT)
smtp.enable_ssl
smtp.start(HELO, ACCESS_KEY, SECRET_KEY, :plain) do |smtp|
smtp.send_message msg, FROM_ADDR, TO_ADDR
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment