使用 Ruby 通过 SMTP 协议发信
# install `mail` gem first: `gem install mail`
require 'mail'
Mail.defaults do
delivery_method :smtp, {
:port => 25,
:address => "smtpdm.aliyun.com",
:user_name => "domaintest@dm.aliyun.com",
:password => "****",
:enable_starttls_auto => false,
:openssl_verify_mode => 'none',
}
end
mail = Mail.deliver do
to 'test@test.com'
from 'domaintest@dm.aliyun.com'
subject 'Hello'
text_part do
body 'Testing mail'
end
end
注:请在 :user_name => 后替换您的发信地址;:password => 后替换您的邮件推送密码;to ‘后替换接收地址;from ‘后替换发信地址。