Created
June 6, 2012 02:17
-
-
Save wxianfeng/2879449 to your computer and use it in GitHub Desktop.
ruby net/smtp send mail
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 | |
#!/usr/bin/env ruby | |
require 'net/smtp' | |
FROM = '[email protected]' | |
TO = '[email protected]' | |
value = ["[www.entfield.com]请激活您的帐号"].pack("M").gsub(/=\n/, "") | |
subject = "=?UTF-8?Q?#{value}?=" | |
message_html =<<HERE | |
From: noreply <[email protected]> | |
To: #{TO} <#{TO}> | |
Content-Type: text/html;charset=utf-8 | |
Charset: UTF-8 | |
Subject: #{subject} | |
<style type="text/css" media="screen"> | |
body{background:url(http://www.entfield.com/images/entrybg.png) repeat;margin:0;font-family: 宋体,Tahoma,Verdana,sans-serif,simsun,Arial;font-size:14px;color:#333;} | |
.main{width:600px;height: 330px;margin:30px 100px;padding:25px 50px;background:#fff;border:1px solid #cfcfcf; | |
-moz-box-shadow:2px 2px 5px #333;-webkit-box-shadow:2px 2px 5px #333; box-shadow:2px 2px 5px #333;} | |
.hdr{margin-bottom:25px;color:#666;height:48px;border-bottom:1px solid #6cc5d9;background:url(http://www.entfield.com/images/logo.png) no-repeat;} | |
p{margin:8px 0;} | |
span{color:#999;} | |
.ent,.title{font-weight:bold;margin:20px 0;} | |
.ent{color:#666;} | |
</style> | |
<body> | |
<div class="main"> | |
<div class="hdr"></div> | |
<div class="content"> | |
<p class="title">#{TO}:</p> | |
<p>感谢您的注册!请点击下面的链接完成加入Entsea。<span>(填写个人资料,加入或创建您的公司)</span></p> | |
<p><a href="www.entfield.com">www.entfield.com</a></p> | |
<p><span>(如无法直接打开链接,请将链接直接复制到您使用的浏览器窗口地址栏内使用)</span></p> | |
<p class="ent">Entsea Team</p> | |
</div> | |
</div> | |
</body> | |
HERE | |
resp = Net::SMTP.start('smtp_server', 25, 'ehlo_domain','user', 'password', :plain) do |smtp| | |
smtp.send_message(message_html, FROM, TO) | |
end | |
p resp.status |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment