Last active
December 21, 2015 01:49
-
-
Save wagurano/6231026 to your computer and use it in GitHub Desktop.
지메일로 편지쓰기(루비 코드)
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
# encoding: utf-8 | |
# ruby 1.9 | |
require 'net/smtp' | |
require 'tlsmail' | |
require "time" | |
require "base64" | |
def sendmails from, to, contents | |
begin | |
Net::SMTP.enable_tls(OpenSSL::SSL::VERIFY_NONE) | |
Net::SMTP.start("smtp.gmail.com", "587", "gmail.com", "your_id@gmail.com", "your_password", :plain) do |smtp| | |
header = "Content-type: text/plain; charset=UTF-8\n" \ | |
+ "From: =?UTF-8?B?" + Base64.strict_encode64("00 운영팀(김00) " + from) + "?=\n" \ | |
+ "To: " + to + "\n" \ | |
+ "Subject: =?UTF-8?B?" + Base64.strict_encode64("새해 복 많이 받으세요.") + "?=\n" | |
message = header + contents | |
smtp.send_message message, from, to | |
puts from, to, message | |
end | |
end | |
end | |
msg = <<END_OF_MESSAGE | |
Date: #{Time.now.rfc2822} | |
지난 00기간 동안 적극적으로 참여해주셔서 감사합니다. | |
새해에도 건강하시고 많은 축복 받으시기를 진심으로 기원합니다. | |
----- | |
000에서는 .....합니다. | |
================================================================================ | |
이메일 수신을 원치 않으시면 xxxxxxxxx@gmail.com 으로 보내주시기 바랍니다. | |
END_OF_MESSAGE | |
sendmails "your_id@gmail.com", "receiver@example.com", msg |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment