مراية لـ
https://github.com/postalserver/postal.git
تم المزامنة 2025-11-30 21:32:30 +00:00
fix: retry connections without SSL when SSL issue is encountered during smtp sending
هذا الالتزام موجود في:
@@ -46,13 +46,16 @@ module Postal
|
|||||||
end
|
end
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
|
|
||||||
smtp_client = Net::SMTP.new(hostname, port)
|
smtp_client = Net::SMTP.new(hostname, port)
|
||||||
smtp_client.open_timeout = Postal.config.smtp_client.open_timeout
|
smtp_client.open_timeout = Postal.config.smtp_client.open_timeout
|
||||||
smtp_client.read_timeout = Postal.config.smtp_client.read_timeout
|
smtp_client.read_timeout = Postal.config.smtp_client.read_timeout
|
||||||
|
|
||||||
if @source_ip_address
|
if @source_ip_address
|
||||||
# Set the source IP as appropriate
|
# Set the source IP as appropriate
|
||||||
smtp_client.source_address = ip_type == :aaaa ? @source_ip_address.ipv6 : @source_ip_address.ipv4
|
smtp_client.source_address = ip_type == :aaaa ? @source_ip_address.ipv6 : @source_ip_address.ipv4
|
||||||
end
|
end
|
||||||
|
|
||||||
case ssl_mode
|
case ssl_mode
|
||||||
when 'Auto'
|
when 'Auto'
|
||||||
smtp_client.enable_starttls_auto(self.class.ssl_context_without_verify)
|
smtp_client.enable_starttls_auto(self.class.ssl_context_without_verify)
|
||||||
@@ -63,9 +66,17 @@ module Postal
|
|||||||
else
|
else
|
||||||
# Nothing
|
# Nothing
|
||||||
end
|
end
|
||||||
|
|
||||||
smtp_client.start(@source_ip_address ? @source_ip_address.hostname : self.class.default_helo_hostname)
|
smtp_client.start(@source_ip_address ? @source_ip_address.hostname : self.class.default_helo_hostname)
|
||||||
log "Connected to #{@remote_ip}:#{port} (#{hostname})"
|
log "Connected to #{@remote_ip}:#{port} (#{hostname})"
|
||||||
|
|
||||||
rescue => e
|
rescue => e
|
||||||
|
if e.is_a?(OpenSSL::SSL::SSLError) && ssl_mode == 'Auto'
|
||||||
|
log "SSL error (#{e.message}), retrying without SSL"
|
||||||
|
ssl_mode = nil
|
||||||
|
retry
|
||||||
|
end
|
||||||
|
|
||||||
log "Cannot connect to #{@remote_ip}:#{port} (#{hostname}) (#{e.class}: #{e.message})"
|
log "Cannot connect to #{@remote_ip}:#{port} (#{hostname}) (#{e.class}: #{e.message})"
|
||||||
@connection_errors << e.message unless @connection_errors.include?(e.message)
|
@connection_errors << e.message unless @connection_errors.include?(e.message)
|
||||||
smtp_client.disconnect rescue nil
|
smtp_client.disconnect rescue nil
|
||||||
|
|||||||
المرجع في مشكلة جديدة
حظر مستخدم