From 450d82151ffe51c85da58463dc26ca626bf62f03 Mon Sep 17 00:00:00 2001 From: Lewis Buckley Date: Wed, 3 Nov 2021 11:30:00 +0000 Subject: [PATCH] Support Net::SMTP#start tls_verify and tls_hostname options in Ruby 3 --- lib/mail/network/delivery_methods/smtp.rb | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/lib/mail/network/delivery_methods/smtp.rb b/lib/mail/network/delivery_methods/smtp.rb index deedde93a..c83c2d196 100644 --- a/lib/mail/network/delivery_methods/smtp.rb +++ b/lib/mail/network/delivery_methods/smtp.rb @@ -106,7 +106,25 @@ def deliver!(mail) private def start_smtp_session(&block) - build_smtp_session.start(settings[:domain], settings[:user_name], settings[:password], settings[:authentication], &block) + if RUBY_VERSION >= '3.0' + build_smtp_session.start( + settings[:domain], + settings[:user_name], + settings[:password], + settings[:authentication], + tls_hostname: settings[:tls_hostname], + tls_verify: settings[:tls_verify], + &block + ) + else + build_smtp_session.start( + settings[:domain], + settings[:user_name], + settings[:password], + settings[:authentication], + &block + ) + end end def build_smtp_session