From 1e28f9701c65cffbeac9ec40c29756e2745b4cfc Mon Sep 17 00:00:00 2001 From: Quinn Damerell Date: Tue, 18 Jun 2024 08:23:20 -0700 Subject: [PATCH] feat(smtp): add config option to disable sending email via ipv6 --- app/senders/smtp_sender.rb | 4 ++-- lib/postal/config_schema.rb | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/app/senders/smtp_sender.rb b/app/senders/smtp_sender.rb index 1f3c863f..6107d3eb 100644 --- a/app/senders/smtp_sender.rb +++ b/app/senders/smtp_sender.rb @@ -177,8 +177,8 @@ def resolve_mx_records_for_domain # @param endpoint [SMTPClient::Endpoint] # @return [Boolean] def connect_to_endpoint(endpoint, allow_ssl: true) - if @source_ip_address && @source_ip_address.ipv6.blank? && endpoint.ipv6? - # Don't try to use IPv6 if the IP address we're sending from doesn't support it. + if (@source_ip_address && @source_ip_address.ipv6.blank? && endpoint.ipv6?) || Postal::Config.smtp.disable_ipv6 + # Don't try to use IPv6 if the IP address we're sending from doesn't support it or if it's disabled in the config. return false end diff --git a/lib/postal/config_schema.rb b/lib/postal/config_schema.rb index af3c7330..147f24db 100644 --- a/lib/postal/config_schema.rb +++ b/lib/postal/config_schema.rb @@ -413,6 +413,11 @@ module Postal description "The e-mail to use as the from address outgoing emails from Postal" default "postal@example.com" end + + boolean :disable_ipv6 do + description "Disalbles sending emails via IPv6, only IPv4 will be used" + default false + end end group :rails do