如何使用ssl通过smtp发送带有ruby的邮件(不带有rails,没有用于gmail的TLS)

11 ruby ssl smtp

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

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

我发现有人在讨论使用ruby 1.8.5的SMTPS支持,但是libdoc没有提到它.

是否有人通过端口465通过SMTP发送邮件的示例?

ruby -v
ruby 1.8.7 (2008-08-11 patchlevel 72) [i486-linux]
Run Code Online (Sandbox Code Playgroud)

小智 10

我通过以下配置解决了这个问题:

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.
}
Run Code Online (Sandbox Code Playgroud)

它对我很有用.


Mik*_*use 0

您可能已经了解Net::SMTP 标准库

关于 SSL 部分,似乎不支持开箱即用,我发现了一些可能的提示: