ruby发送邮件方法

#encoding:utf-8
require 'mail'
def send_email sum,fail,case_path,name,receive
smtp = { :address => '***', :port => 25, :domain => '***',
:user_name => '****', :password => '***',
:enable_starttls_auto => true, :openssl_verify_mode => 'none' }
Mail.defaults { delivery_method :smtp, smtp }
mail = Mail.new do
from '****'
to receive
subject '自动化测试报告'
body "各位好:
附件为#{name.encode('utf-8')},请查看。
总结如下:本次回归共#{sum}个用例,失败#{fail}个

"
add_file File.expand_path(case_path)
end
mail.deliver!
end
原文地址:https://www.cnblogs.com/anion-blogs/p/5850597.html