如何使用 ssl 通过 smtp 使用 ruby​​ 发送邮件(不使用 rails,gmail 没有 TLS) [英] How to send mail with ruby over smtp with ssl (not with rails, no TLS for gmail)

查看:52
本文介绍了如何使用 ssl 通过 smtp 使用 ruby​​ 发送邮件(不使用 rails,gmail 没有 TLS)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要的只是使用 SSL 通过 SMTP 从我的 ruby​​ 脚本发送电子邮件.

All I want is to send emails from my ruby scripts, over SMTP using SSL.

我只找到从 Rails 或使用 TLS 的 Gmail 执行此操作的示例.

I only find examples of doing it from Rails, or for Gmail with TLS.

我发现人们在谈论 ruby​​ 1.8.5 支持 SMTPS,但是 libdoc 没有提到它.

I found people talking about SMTPS support with ruby 1.8.5, but the libdoc doesn't mention it.

任何人都知道使用 SSL 在 465 端口上通过 SMTP 发送邮件的示例?

Anyone with an example of sending mail over SMTP with SSL, on port 465?

ruby -v
ruby 1.8.7 (2008-08-11 patchlevel 72) [i486-linux]

推荐答案

我用下面的配置解决了这个问题:

I solve this issue with this configuration below :

config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = false
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
    :address              => 'mail.domain.com',
    :port                 => '465',
    :domain               => 'yourdomain.com',
    :user_name            => 'email@yourdomain.com',
    :password             => 'yourpassword',
    :authentication       => :login,
    :ssl                  => true,
    :openssl_verify_mode  => 'none' #Use this because ssl is activated but we have no certificate installed. So clients need to confirm to use the untrusted url.
}

它对我来说效果很好.

这篇关于如何使用 ssl 通过 smtp 使用 ruby​​ 发送邮件(不使用 rails,gmail 没有 TLS)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆