Skip to content

Commit

Permalink
fix: explicitly disable TLS & starttls for unknown SSL modes
Browse files Browse the repository at this point in the history
closes #2564
  • Loading branch information
adamcooke committed Feb 13, 2024
1 parent f9f7fb3 commit 42ab5b3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
4 changes: 4 additions & 0 deletions lib/postal/smtp_sender.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,17 @@ def start
# Set the source IP as appropriate
smtp_client.source_address = ip_type == :aaaa ? @source_ip_address.ipv6 : @source_ip_address.ipv4
end

case ssl_mode
when "Auto"
smtp_client.enable_starttls_auto(self.class.ssl_context_without_verify)
when "STARTTLS"
smtp_client.enable_starttls(self.class.ssl_context_with_verify)
when "TLS"
smtp_client.enable_tls(self.class.ssl_context_with_verify)
else
smtp_client.disable_starttls
smtp_client.disable_tls
end

smtp_client.start(@source_ip_address ? @source_ip_address.hostname : self.class.default_helo_hostname)
Expand Down
16 changes: 15 additions & 1 deletion script/send_html_email.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,24 @@
BODY
end

# puts mail.to_s
c = OpenSSL::SSL::SSLContext.new
c.verify_mode = OpenSSL::SSL::VERIFY_NONE

<<<<<<< Updated upstream
Net::SMTP.start("127.0.0.1", 2525) do |smtp|
smtp.send_message mail.to_s, mail.from.first, mail.to.first
end
=======
1000.times.map do
Thread.new do
smtp = Net::SMTP.new("77.72.7.155", 25)
# smtp.enable_starttls(c)
smtp.disable_starttls
smtp.start("localhost")
smtp.send_message mail.to_s, mail.from.first, mail.to.first
smtp.finish
end
end.each(&:join)
>>>>>>> Stashed changes

puts "Sent"

0 comments on commit 42ab5b3

Please sign in to comment.