مراية لـ
https://github.com/postalserver/postal.git
تم المزامنة 2025-11-30 21:32:30 +00:00
feat: new configuration system (and schema) (#2819)
هذا الالتزام موجود في:
@@ -8,9 +8,9 @@ class DKIMHeader
|
||||
@dkim_key = domain.dkim_key
|
||||
@dkim_identifier = domain.dkim_identifier
|
||||
else
|
||||
@domain_name = Postal.config.dns.return_path
|
||||
@domain_name = Postal::Config.dns.return_path_domain
|
||||
@dkim_key = Postal.signing_key
|
||||
@dkim_identifier = Postal.config.dns.dkim_identifier
|
||||
@dkim_identifier = Postal::Config.dns.dkim_identifier
|
||||
end
|
||||
@domain = domain
|
||||
@message = message
|
||||
|
||||
@@ -48,7 +48,7 @@ module MessageDequeuer
|
||||
end
|
||||
|
||||
def check_delivery_attempts
|
||||
return if queued_message.attempts < Postal.config.general.maximum_delivery_attempts
|
||||
return if queued_message.attempts < Postal::Config.postal.default_maximum_delivery_attempts
|
||||
|
||||
details = "Maximum number of delivery attempts (#{queued_message.attempts}) has been reached."
|
||||
if queued_message.message.scope == "incoming"
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
class ReceivedHeader
|
||||
|
||||
OUR_HOSTNAMES = {
|
||||
smtp: Postal.config.dns.smtp_server_hostname,
|
||||
http: Postal.config.web.host
|
||||
smtp: Postal::Config.postal.smtp_hostname,
|
||||
http: Postal::Config.postal.web_hostname
|
||||
}.freeze
|
||||
|
||||
class << self
|
||||
|
||||
@@ -1,36 +1,34 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Postal
|
||||
class ReplySeparator
|
||||
class ReplySeparator
|
||||
|
||||
RULES = [
|
||||
/^-{2,10} $.*/m,
|
||||
/^>*\s*----- ?Original Message ?-----.*/m,
|
||||
/^>*\s*From:[^\r\n]*[\r\n]+Sent:.*/m,
|
||||
/^>*\s*From:[^\r\n]*[\r\n]+Date:.*/m,
|
||||
/^>*\s*-----Urspr.ngliche Nachricht----- .*/m,
|
||||
/^>*\s*Le[^\r\n]{10,200}a .crit ?:\s*$.*/,
|
||||
/^>*\s*__________________.*/m,
|
||||
/^>*\s*On.{10,200}wrote:\s*$.*/m,
|
||||
/^>*\s*Sent from my.*/m,
|
||||
/^>*\s*=== Please reply above this line ===.*/m,
|
||||
/(^>.*\n?){10,}/
|
||||
].freeze
|
||||
RULES = [
|
||||
/^-{2,10} $.*/m,
|
||||
/^>*\s*----- ?Original Message ?-----.*/m,
|
||||
/^>*\s*From:[^\r\n]*[\r\n]+Sent:.*/m,
|
||||
/^>*\s*From:[^\r\n]*[\r\n]+Date:.*/m,
|
||||
/^>*\s*-----Urspr.ngliche Nachricht----- .*/m,
|
||||
/^>*\s*Le[^\r\n]{10,200}a .crit ?:\s*$.*/,
|
||||
/^>*\s*__________________.*/m,
|
||||
/^>*\s*On.{10,200}wrote:\s*$.*/m,
|
||||
/^>*\s*Sent from my.*/m,
|
||||
/^>*\s*=== Please reply above this line ===.*/m,
|
||||
/(^>.*\n?){10,}/
|
||||
].freeze
|
||||
|
||||
def self.separate(text)
|
||||
return "" unless text.is_a?(String)
|
||||
def self.separate(text)
|
||||
return "" unless text.is_a?(String)
|
||||
|
||||
text = text.gsub("\r", "")
|
||||
stripped = String.new
|
||||
RULES.each do |rule|
|
||||
text.gsub!(rule) do
|
||||
stripped = ::Regexp.last_match(0).to_s + "\n" + stripped
|
||||
""
|
||||
end
|
||||
text = text.gsub("\r", "")
|
||||
stripped = String.new
|
||||
RULES.each do |rule|
|
||||
text.gsub!(rule) do
|
||||
stripped = ::Regexp.last_match(0).to_s + "\n" + stripped
|
||||
""
|
||||
end
|
||||
stripped = stripped.strip
|
||||
[text.strip, stripped.presence]
|
||||
end
|
||||
|
||||
stripped = stripped.strip
|
||||
[text.strip, stripped.presence]
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -32,7 +32,9 @@ module SMTPServer
|
||||
end
|
||||
|
||||
def check_ip_address
|
||||
return unless @ip_address && Postal.config.smtp_server.log_exclude_ips && @ip_address =~ Regexp.new(Postal.config.smtp_server.log_exclude_ips)
|
||||
return unless @ip_address &&
|
||||
Postal::Config.smtp_server.log_ip_address_exclusion_matcher &&
|
||||
@ip_address =~ Regexp.new(Postal::Config.smtp_server.log_ip_address_exclusion_matcher)
|
||||
|
||||
@logging_enabled = false
|
||||
end
|
||||
@@ -109,7 +111,7 @@ module SMTPServer
|
||||
@state = :welcome
|
||||
log "\e[35m Client identified as #{@ip_address}\e[0m"
|
||||
increment_command_count("PROXY")
|
||||
"220 #{Postal.config.dns.smtp_server_hostname} ESMTP Postal/#{id}"
|
||||
"220 #{Postal::Config.postal.smtp_hostname} ESMTP Postal/#{id}"
|
||||
else
|
||||
@finished = true
|
||||
increment_error_count("proxy-error")
|
||||
@@ -123,7 +125,7 @@ module SMTPServer
|
||||
end
|
||||
|
||||
def starttls
|
||||
if Postal.config.smtp_server.tls_enabled?
|
||||
if Postal::Config.smtp_server.tls_enabled?
|
||||
@start_tls = true
|
||||
@tls = true
|
||||
increment_command_count("STARTLS")
|
||||
@@ -141,7 +143,7 @@ module SMTPServer
|
||||
increment_command_count("EHLO")
|
||||
[
|
||||
"250-My capabilities are",
|
||||
Postal.config.smtp_server.tls_enabled? && !@tls ? "250-STARTTLS" : nil,
|
||||
Postal::Config.smtp_server.tls_enabled? && !@tls ? "250-STARTTLS" : nil,
|
||||
"250 AUTH CRAM-MD5 PLAIN LOGIN"
|
||||
].compact
|
||||
end
|
||||
@@ -151,7 +153,7 @@ module SMTPServer
|
||||
transaction_reset
|
||||
@state = :welcomed
|
||||
increment_command_count("HELO")
|
||||
"250 #{Postal.config.dns.smtp_server_hostname}"
|
||||
"250 #{Postal::Config.postal.smtp_hostname}"
|
||||
end
|
||||
|
||||
def rset
|
||||
@@ -231,7 +233,7 @@ module SMTPServer
|
||||
increment_command_count("AUTH CRAM-MD5")
|
||||
|
||||
challenge = Digest::SHA1.hexdigest(Time.now.to_i.to_s + rand(100_000).to_s)
|
||||
challenge = "<#{challenge[0, 20]}@#{Postal.config.dns.smtp_server_hostname}>"
|
||||
challenge = "<#{challenge[0, 20]}@#{Postal::Config.postal.smtp_hostname}>"
|
||||
|
||||
handler = proc do |idata|
|
||||
@proc = nil
|
||||
@@ -309,7 +311,7 @@ module SMTPServer
|
||||
|
||||
uname, tag = uname.split("+", 2)
|
||||
|
||||
if domain == Postal.config.dns.return_path || domain =~ /\A#{Regexp.escape(Postal.config.dns.custom_return_path_prefix)}\./
|
||||
if domain == Postal::Config.dns.return_path_domain || domain =~ /\A#{Regexp.escape(Postal::Config.dns.custom_return_path_prefix)}\./
|
||||
# This is a return path
|
||||
@state = :rcpt_to_received
|
||||
if server = ::Server.where(token: uname).first
|
||||
@@ -326,7 +328,7 @@ module SMTPServer
|
||||
"550 Invalid server token"
|
||||
end
|
||||
|
||||
elsif domain == Postal.config.dns.route_domain
|
||||
elsif domain == Postal::Config.dns.route_domain
|
||||
# This is an email direct to a route. This isn't actually supported yet.
|
||||
@state = :rcpt_to_received
|
||||
if route = Route.where(token: uname).first
|
||||
@@ -446,14 +448,14 @@ module SMTPServer
|
||||
end
|
||||
|
||||
def finished
|
||||
if @data.bytesize > Postal.config.smtp_server.max_message_size.megabytes.to_i
|
||||
if @data.bytesize > Postal::Config.smtp_server.max_message_size.megabytes.to_i
|
||||
transaction_reset
|
||||
@state = :welcomed
|
||||
increment_error_count("message-too-large")
|
||||
return format("552 Message too large (maximum size %dMB)", Postal.config.smtp_server.max_message_size)
|
||||
return format("552 Message too large (maximum size %dMB)", Postal::Config.smtp_server.max_message_size)
|
||||
end
|
||||
|
||||
if @headers["received"].grep(/by #{Postal.config.dns.smtp_server_hostname}/).count > 4
|
||||
if @headers["received"].grep(/by #{Postal::Config.postal.smtp_hostname}/).count > 4
|
||||
transaction_reset
|
||||
@state = :welcomed
|
||||
increment_error_count("loop-detected")
|
||||
|
||||
@@ -8,6 +8,24 @@ module SMTPServer
|
||||
|
||||
include HasPrometheusMetrics
|
||||
|
||||
class << self
|
||||
|
||||
def tls_private_key
|
||||
@tls_private_key ||= OpenSSL::PKey.read(File.read(Postal::Config.smtp_server.tls_private_key_path))
|
||||
end
|
||||
|
||||
def tls_certificates
|
||||
@tls_certificates ||= begin
|
||||
data = File.read(Postal::Config.smtp_server.tls_certificate_path)
|
||||
certs = data.scan(/-----BEGIN CERTIFICATE-----.+?-----END CERTIFICATE-----/m)
|
||||
certs.map do |c|
|
||||
OpenSSL::X509::Certificate.new(c)
|
||||
end.freeze
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def initialize(options = {})
|
||||
@options = options
|
||||
@options[:debug] ||= false
|
||||
@@ -43,16 +61,19 @@ module SMTPServer
|
||||
@ssl_context ||= begin
|
||||
ssl_context = OpenSSL::SSL::SSLContext.new
|
||||
ssl_context.cert = Postal.smtp_certificates[0]
|
||||
ssl_context.extra_chain_cert = Postal.smtp_certificates[1..]
|
||||
ssl_context.key = Postal.smtp_private_key
|
||||
ssl_context.ssl_version = Postal.config.smtp_server.ssl_version if Postal.config.smtp_server.ssl_version
|
||||
ssl_context.ciphers = Postal.config.smtp_server.tls_ciphers if Postal.config.smtp_server.tls_ciphers
|
||||
ssl_context.extra_chain_cert = self.class.tls_certificates[1..]
|
||||
ssl_context.key = self.class.tls_private_key
|
||||
ssl_context.ssl_version = Postal::Config.smtp_server.ssl_version if Postal::Config.smtp_server.ssl_version
|
||||
ssl_context.ciphers = Postal::Config.smtp_server.tls_ciphers if Postal::Config.smtp_server.tls_ciphers
|
||||
ssl_context
|
||||
end
|
||||
end
|
||||
|
||||
def listen
|
||||
@server = TCPServer.open(Postal.config.smtp_server.bind_address, Postal.config.smtp_server.port)
|
||||
bind_address = ENV.fetch("BIND_ADDRESS", Postal::Config.smtp_server.default_bind_address)
|
||||
port = ENV.fetch("PORT", Postal::Config.smtp_server.default_port)
|
||||
|
||||
@server = TCPServer.open(bind_address, port)
|
||||
@server.autoclose = false
|
||||
@server.close_on_exec = false
|
||||
if defined?(Socket::SOL_SOCKET) && defined?(Socket::SO_KEEPALIVE)
|
||||
@@ -63,7 +84,8 @@ module SMTPServer
|
||||
@server.setsockopt(Socket::SOL_TCP, Socket::TCP_KEEPINTVL, 10)
|
||||
@server.setsockopt(Socket::SOL_TCP, Socket::TCP_KEEPCNT, 5)
|
||||
end
|
||||
logger.info "Listening on #{Postal.config.smtp_server.bind_address}:#{Postal.config.smtp_server.port}"
|
||||
|
||||
logger.info "Listening on #{bind_address}:#{port}"
|
||||
end
|
||||
|
||||
def unlisten
|
||||
@@ -90,22 +112,22 @@ module SMTPServer
|
||||
# Accept the connection
|
||||
new_io = io.accept
|
||||
increment_prometheus_counter :postal_smtp_server_connections_total
|
||||
if Postal.config.smtp_server.proxy_protocol
|
||||
if Postal::Config.smtp_server.proxy_protocol?
|
||||
# If we are using the haproxy proxy protocol, we will be sent the
|
||||
# client's IP later. Delay the welcome process.
|
||||
client = Client.new(nil)
|
||||
if Postal.config.smtp_server.log_connect
|
||||
if Postal::Config.smtp_server.log_connections?
|
||||
logger.debug "[#{client.id}] \e[35m Connection opened from #{new_io.remote_address.ip_address}\e[0m"
|
||||
end
|
||||
else
|
||||
# We're not using the proxy protocol so we already know the client's IP
|
||||
client = Client.new(new_io.remote_address.ip_address)
|
||||
if Postal.config.smtp_server.log_connect
|
||||
if Postal::Config.smtp_server.log_connections?
|
||||
logger.debug "[#{client.id}] \e[35m Connection opened from #{new_io.remote_address.ip_address}\e[0m"
|
||||
end
|
||||
# We know who the client is, welcome them.
|
||||
client.log "\e[35m Client identified as #{new_io.remote_address.ip_address}\e[0m"
|
||||
new_io.print("220 #{Postal.config.dns.smtp_server_hostname} ESMTP Postal/#{client.id}")
|
||||
new_io.print("220 #{Postal::Config.postal.smtp_hostname} ESMTP Postal/#{client.id}")
|
||||
end
|
||||
# Register the client and its socket with nio4r
|
||||
monitor = @io_selector.register(new_io, :r)
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
class ApplicationMailer < ActionMailer::Base
|
||||
|
||||
default from: "#{Postal.smtp_from_name} <#{Postal.smtp_from_address}>"
|
||||
default from: "#{Postal::Config.smtp.from_name} <#{Postal::Config.smtp.from_address}>"
|
||||
layout false
|
||||
|
||||
end
|
||||
|
||||
@@ -14,7 +14,7 @@ class BounceMessage
|
||||
mail.subject = "Mail Delivery Failed (#{@message.subject})"
|
||||
mail.text_part = body
|
||||
mail.attachments["Original Message.eml"] = { mime_type: "message/rfc822", encoding: "quoted-printable", content: @message.raw_message }
|
||||
mail.message_id = "<#{SecureRandom.uuid}@#{Postal.config.dns.return_path}>"
|
||||
mail.message_id = "<#{SecureRandom.uuid}@#{Postal::Config.dns.return_path_domain}>"
|
||||
mail.to_s
|
||||
end
|
||||
|
||||
@@ -32,7 +32,7 @@ class BounceMessage
|
||||
end
|
||||
|
||||
def postmaster_address
|
||||
@server.postmaster_address || "postmaster@#{@message.domain&.name || Postal.config.web.host}"
|
||||
@server.postmaster_address || "postmaster@#{@message.domain&.name || Postal::Config.postal.web_hostname}"
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -49,10 +49,10 @@ module HasDNSChecks
|
||||
self.spf_status = "Missing"
|
||||
self.spf_error = "No SPF record exists for this domain"
|
||||
else
|
||||
suitable_spf_records = spf_records.grep(/include:\s*#{Regexp.escape(Postal.config.dns.spf_include)}/)
|
||||
suitable_spf_records = spf_records.grep(/include:\s*#{Regexp.escape(Postal::Config.dns.spf_include)}/)
|
||||
if suitable_spf_records.empty?
|
||||
self.spf_status = "Invalid"
|
||||
self.spf_error = "An SPF record exists but it doesn't include #{Postal.config.dns.spf_include}"
|
||||
self.spf_error = "An SPF record exists but it doesn't include #{Postal::Config.dns.spf_include}"
|
||||
false
|
||||
else
|
||||
self.spf_status = "OK"
|
||||
@@ -108,11 +108,11 @@ module HasDNSChecks
|
||||
self.mx_status = "Missing"
|
||||
self.mx_error = "There are no MX records for #{name}"
|
||||
else
|
||||
missing_records = Postal.config.dns.mx_records.dup - records.map { |r| r.to_s.downcase }
|
||||
missing_records = Postal::Config.dns.mx_records.dup - records.map { |r| r.to_s.downcase }
|
||||
if missing_records.empty?
|
||||
self.mx_status = "OK"
|
||||
self.mx_error = nil
|
||||
elsif missing_records.size == Postal.config.dns.mx_records.size
|
||||
elsif missing_records.size == Postal::Config.dns.mx_records.size
|
||||
self.mx_status = "Missing"
|
||||
self.mx_error = "You have MX records but none of them point to us."
|
||||
else
|
||||
@@ -136,12 +136,12 @@ module HasDNSChecks
|
||||
if records.empty?
|
||||
self.return_path_status = "Missing"
|
||||
self.return_path_error = "There is no return path record at #{return_path_domain}"
|
||||
elsif records.size == 1 && records.first == Postal.config.dns.return_path
|
||||
elsif records.size == 1 && records.first == Postal::Config.dns.return_path_domain
|
||||
self.return_path_status = "OK"
|
||||
self.return_path_error = nil
|
||||
else
|
||||
self.return_path_status = "Invalid"
|
||||
self.return_path_error = "There is a CNAME record at #{return_path_domain} but it points to #{records.first} which is incorrect. It should point to #{Postal.config.dns.return_path}."
|
||||
self.return_path_error = "There is a CNAME record at #{return_path_domain} but it points to #{records.first} which is incorrect. It should point to #{Postal::Config.dns.return_path_domain}."
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -104,7 +104,7 @@ class Domain < ApplicationRecord
|
||||
end
|
||||
|
||||
def spf_record
|
||||
"v=spf1 a mx include:#{Postal.config.dns.spf_include} ~all"
|
||||
"v=spf1 a mx include:#{Postal::Config.dns.spf_include} ~all"
|
||||
end
|
||||
|
||||
def dkim_record
|
||||
@@ -117,7 +117,7 @@ class Domain < ApplicationRecord
|
||||
def dkim_identifier
|
||||
return nil unless dkim_identifier_string
|
||||
|
||||
Postal.config.dns.dkim_identifier + "-#{dkim_identifier_string}"
|
||||
Postal::Config.dns.dkim_identifier + "-#{dkim_identifier_string}"
|
||||
end
|
||||
|
||||
def dkim_record_name
|
||||
@@ -128,7 +128,7 @@ class Domain < ApplicationRecord
|
||||
end
|
||||
|
||||
def return_path_domain
|
||||
"#{Postal.config.dns.custom_return_path_prefix}.#{name}"
|
||||
"#{Postal::Config.dns.custom_return_path_prefix}.#{name}"
|
||||
end
|
||||
|
||||
# Returns a DNSResolver instance that can be used to perform DNS lookups needed for
|
||||
@@ -136,13 +136,13 @@ class Domain < ApplicationRecord
|
||||
#
|
||||
# @return [DNSResolver]
|
||||
def resolver
|
||||
return DNSResolver.local if Postal.config.general.use_local_ns_for_domains?
|
||||
return DNSResolver.local if Postal::Config.postal.use_local_ns_for_domain_verification?
|
||||
|
||||
@resolver ||= DNSResolver.for_domain(name)
|
||||
end
|
||||
|
||||
def dns_verification_string
|
||||
"#{Postal.config.dns.domain_verify_prefix} #{verification_token}"
|
||||
"#{Postal::Config.dns.domain_verify_prefix} #{verification_token}"
|
||||
end
|
||||
|
||||
def verify_with_dns
|
||||
|
||||
@@ -88,7 +88,7 @@ class IncomingMessagePrototype
|
||||
mail.from = @from
|
||||
mail.subject = @subject
|
||||
mail.text_part = @plain_body
|
||||
mail.message_id = "<#{SecureRandom.uuid}@#{Postal.config.dns.return_path}>"
|
||||
mail.message_id = "<#{SecureRandom.uuid}@#{Postal::Config.dns.return_path_domain}>"
|
||||
attachments.each do |attachment|
|
||||
mail.attachments[attachment[:name]] = {
|
||||
mime_type: attachment[:content_type],
|
||||
|
||||
@@ -25,7 +25,7 @@ class OutgoingMessagePrototype
|
||||
@source_type = source_type
|
||||
@custom_headers = {}
|
||||
@attachments = []
|
||||
@message_id = "#{SecureRandom.uuid}@#{Postal.config.dns.return_path}"
|
||||
@message_id = "#{SecureRandom.uuid}@#{Postal::Config.dns.return_path_domain}"
|
||||
attributes.each do |key, value|
|
||||
instance_variable_set("@#{key}", value)
|
||||
end
|
||||
|
||||
@@ -89,7 +89,7 @@ class Route < ApplicationRecord
|
||||
end
|
||||
|
||||
def forward_address
|
||||
@forward_address ||= "#{token}@#{Postal.config.dns.route_domain}"
|
||||
@forward_address ||= "#{token}@#{Postal::Config.dns.route_domain}"
|
||||
end
|
||||
|
||||
def wildcard?
|
||||
|
||||
@@ -71,8 +71,8 @@ class Server < ApplicationRecord
|
||||
default_value :raw_message_retention_days, -> { 30 }
|
||||
default_value :raw_message_retention_size, -> { 2048 }
|
||||
default_value :message_retention_days, -> { 60 }
|
||||
default_value :spam_threshold, -> { Postal.config.general.default_spam_threshold }
|
||||
default_value :spam_failure_threshold, -> { Postal.config.general.default_spam_failure_threshold }
|
||||
default_value :spam_threshold, -> { Postal::Config.postal.default_spam_threshold }
|
||||
default_value :spam_failure_threshold, -> { Postal::Config.postal.default_spam_failure_threshold }
|
||||
|
||||
validates :name, presence: true, uniqueness: { scope: :organization_id, case_sensitive: false }
|
||||
validates :mode, inclusion: { in: MODES }
|
||||
|
||||
@@ -58,12 +58,12 @@ class TrackDomain < ApplicationRecord
|
||||
if records.empty?
|
||||
self.dns_status = "Missing"
|
||||
self.dns_error = "There is no record at #{full_name}"
|
||||
elsif records.size == 1 && records.first == Postal.config.dns.track_domain
|
||||
elsif records.size == 1 && records.first == Postal::Config.dns.track_domain
|
||||
self.dns_status = "OK"
|
||||
self.dns_error = nil
|
||||
else
|
||||
self.dns_status = "Invalid"
|
||||
self.dns_error = "There is a CNAME record at #{full_name} but it points to #{records.first} which is incorrect. It should point to #{Postal.config.dns.track_domain}."
|
||||
self.dns_error = "There is a CNAME record at #{full_name} but it points to #{records.first} which is incorrect. It should point to #{Postal::Config.dns.track_domain}."
|
||||
end
|
||||
self.dns_checked_at = Time.now
|
||||
save!
|
||||
|
||||
@@ -47,8 +47,8 @@ class SMTPSender < BaseSender
|
||||
end
|
||||
|
||||
smtp_client = Net::SMTP.new(@remote_ip, port)
|
||||
smtp_client.open_timeout = Postal.config.smtp_client.open_timeout
|
||||
smtp_client.read_timeout = Postal.config.smtp_client.read_timeout
|
||||
smtp_client.open_timeout = Postal::Config.smtp_client.open_timeout
|
||||
smtp_client.read_timeout = Postal::Config.smtp_client.read_timeout
|
||||
smtp_client.tls_hostname = hostname
|
||||
|
||||
if @source_ip_address
|
||||
@@ -140,9 +140,9 @@ class SMTPSender < BaseSender
|
||||
elsif message.domain.return_path_status == "OK"
|
||||
mail_from = "#{message.server.token}@#{message.domain.return_path_domain}"
|
||||
else
|
||||
mail_from = "#{message.server.token}@#{Postal.config.dns.return_path}"
|
||||
mail_from = "#{message.server.token}@#{Postal::Config.dns.return_path_domain}"
|
||||
end
|
||||
if Postal.config.general.use_resent_sender_header
|
||||
if Postal::Config.postal.use_resent_sender_header
|
||||
raw_message = "Resent-Sender: #{mail_from}\r\n" + message.raw_message
|
||||
else
|
||||
raw_message = message.raw_message
|
||||
@@ -270,15 +270,20 @@ class SMTPSender < BaseSender
|
||||
end
|
||||
|
||||
def default_helo_hostname
|
||||
Postal.config.dns.helo_hostname || Postal.config.dns.smtp_server_hostname || "localhost"
|
||||
Postal::Config.dns.helo_hostname ||
|
||||
Postal::Config.postal.smtp_hostname ||
|
||||
"localhost"
|
||||
end
|
||||
|
||||
def relay_hosts
|
||||
hosts = Postal.config.smtp_relays.map do |relay|
|
||||
next unless relay.hostname.present?
|
||||
relays = Postal::Config.postal.smtp_relays
|
||||
return nil if relays.nil?
|
||||
|
||||
hosts = relays.map do |relay|
|
||||
next unless relay.host.present?
|
||||
|
||||
{
|
||||
hostname: relay.hostname,
|
||||
hostname: relay.host,
|
||||
port: relay.port,
|
||||
ssl_mode: relay.ssl_mode
|
||||
}
|
||||
|
||||
@@ -51,8 +51,9 @@ class HealthServer
|
||||
|
||||
class << self
|
||||
|
||||
def run(default_port: 9090, **options)
|
||||
def run(default_port:, default_bind_address:, **options)
|
||||
port = ENV.fetch("HEALTH_SERVER_PORT", default_port)
|
||||
bind_address = ENV.fetch("HEALTH_SERVER_BIND_ADDRESS", default_bind_address)
|
||||
|
||||
Rack::Handler::WEBrick.run(new(**options),
|
||||
Port: port,
|
||||
@@ -64,10 +65,6 @@ class HealthServer
|
||||
"in use, not starting health server"
|
||||
end
|
||||
|
||||
def bind_address
|
||||
ENV.fetch("HEALTH_SERVER_BIND_ADDRESS", "127.0.0.1")
|
||||
end
|
||||
|
||||
def start(**options)
|
||||
thread = Thread.new { run(**options) }
|
||||
thread.abort_on_exception = false
|
||||
|
||||
@@ -8,5 +8,5 @@ If you didn't request this, you can ignore this e-mail.
|
||||
|
||||
Thanks,
|
||||
|
||||
<%= Postal.smtp_from_name %>
|
||||
<%= Postal.smtp_from_address %>
|
||||
<%= Postal::Config.smtp.from_name %>
|
||||
<%= Postal::Config.smtp.from_address %>
|
||||
|
||||
@@ -13,5 +13,5 @@ You can view more information about this server at:
|
||||
|
||||
Thanks,
|
||||
|
||||
<%= Postal.smtp_from_name %>
|
||||
<%= Postal.smtp_from_address %>
|
||||
<%= Postal::Config.smtp.from_name %>
|
||||
<%= Postal::Config.smtp.from_address %>
|
||||
|
||||
@@ -13,5 +13,5 @@ You can view more information about this server at:
|
||||
|
||||
Thanks,
|
||||
|
||||
<%= Postal.smtp_from_name %>
|
||||
<%= Postal.smtp_from_address %>
|
||||
<%= Postal::Config.smtp.from_name %>
|
||||
<%= Postal::Config.smtp.from_address %>
|
||||
|
||||
@@ -8,5 +8,5 @@ Reason: <%= @server.actual_suspension_reason %>
|
||||
|
||||
Thanks,
|
||||
|
||||
<%= Postal.smtp_from_name %>
|
||||
<%= Postal.smtp_from_address %>
|
||||
<%= Postal::Config.smtp.from_name %>
|
||||
<%= Postal::Config.smtp.from_address %>
|
||||
|
||||
@@ -10,5 +10,5 @@ If you don't agree, just ignore this e-mail.
|
||||
|
||||
Thanks,
|
||||
|
||||
<%= Postal.smtp_from_name %>
|
||||
<%= Postal.smtp_from_address %>
|
||||
<%= Postal::Config.smtp.from_name %>
|
||||
<%= Postal::Config.smtp.from_address %>
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
%p.pageContent__text
|
||||
You need to add a TXT record at the apex/root of your domain (@) with the following
|
||||
content. If you already send mail from another service, you may just need to add
|
||||
<b>include:#{Postal.config.dns.spf_include}</b> to your existing record.
|
||||
<b>include:#{Postal::Config.dns.spf_include}</b> to your existing record.
|
||||
%pre.codeBlock.u-margin= @domain.spf_record
|
||||
|
||||
%h3.pageContent__subTitle DKIM Record
|
||||
@@ -78,7 +78,7 @@
|
||||
%p.pageContent__text
|
||||
This is optional but we recommend adding this to improve deliverability. You should add
|
||||
a <b>CNAME</b> record at <b>#{@domain.return_path_domain}</b> to point to the hostname below.
|
||||
%pre.codeBlock.u-margin= Postal.config.dns.return_path
|
||||
%pre.codeBlock.u-margin= Postal::Config.dns.return_path_domain
|
||||
|
||||
|
||||
%h3.pageContent__subTitle MX Records
|
||||
@@ -99,6 +99,4 @@
|
||||
If you wish to receive incoming e-mail for this domain, you need to add the following MX records
|
||||
to the domain. You don't have to do this and we'll only tell you if they're set up or not. Both
|
||||
records should be priority <b>10</b>.
|
||||
%pre.codeBlock.u-margin= Postal.config.dns.mx_records.join("\n")
|
||||
|
||||
|
||||
%pre.codeBlock.u-margin= Postal::Config.dns.mx_records.join("\n")
|
||||
|
||||
@@ -36,6 +36,5 @@
|
||||
%dl.pageContent__definitions
|
||||
%dt MX Records
|
||||
%dd
|
||||
- for mx in Postal.config.dns.mx_records
|
||||
- for mx in Postal::Config.dns.mx_records
|
||||
%p.pageContent__definitionCode= mx
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
Mail servers can be enabled to send mail from any domain by the administrator.
|
||||
%li
|
||||
If a message cannot be delivered, the system will not send you a bounce message but dispatch a webhook (if you set one up).
|
||||
If a message delivery fails but can be retried, the system will try #{Postal.config.general.maximum_delivery_attempts} times to deliver it before giving up.
|
||||
If a message delivery fails but can be retried, the system will try #{Postal::Config.postal.default_maximum_delivery_attempts} times to deliver it before giving up.
|
||||
.u-margin
|
||||
%h2.pageContent__subTitle Sending using SMTP
|
||||
%p.pageContent__text
|
||||
@@ -27,10 +27,10 @@
|
||||
%dl.pageContent__definitions
|
||||
%dt SMTP Server Address
|
||||
%dd
|
||||
%p.pageContent__definitionCode= Postal.config.dns.smtp_server_hostname
|
||||
%p.pageContent__definitionCode= Postal::Config.postal.smtp_hostname
|
||||
%dt Port
|
||||
%dd
|
||||
%p.pageContent__definitionCode= Postal.config.smtp_server.port
|
||||
%p.pageContent__definitionCode= Postal::Config.smtp_server.default_port
|
||||
%p.pageContent__definitionText
|
||||
The SMTP service supports STARTTLS if you wish to send messages securely. Be aware that security
|
||||
cannot guaranteed all the way to their final destination.
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
- else
|
||||
%p.pageContent__intro.u-margin
|
||||
When messages cannot be delivered, addresses are added to the suppression list which stops
|
||||
future messages to the same recipient being sent through. Recipients are removed from the list after #{Postal.config.general.suppression_list_removal_delay} days.
|
||||
future messages to the same recipient being sent through. Recipients are removed from the list after #{Postal::Config.postal.default_suppression_list_automatic_removal_days} days.
|
||||
%ul.suppressionList
|
||||
- for suppression in @suppressions[:records]
|
||||
%li.suppressionList__item
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
= f.select :domain_id, domain_options_for_select(@server, @track_domain.domain), {}, :class => 'input input--select routeNameInput__domain', :disabled => @track_domain.persisted?
|
||||
%p.fieldSet__text
|
||||
This is the domain that requests for tracked links will be directed through when you use click tracking. We recommend using something like
|
||||
<b>click.yourdomain.com</b>. You will need to a CNAME record to point to <b>#{Postal.config.dns.track_domain}</b> for this once you've added it.
|
||||
<b>click.yourdomain.com</b>. You will need to a CNAME record to point to <b>#{Postal::Config.dns.track_domain}</b> for this once you've added it.
|
||||
|
||||
.fieldSet__field
|
||||
= f.label :ssl_enabled, :class => 'fieldSet__label'
|
||||
@@ -47,4 +47,3 @@
|
||||
|
||||
.fieldSetSubmit.buttonSet
|
||||
= f.submit @track_domain.new_record? ? "Create Track Domain" : "Save Track Domain", :class => 'button button--positive js-form-submit'
|
||||
|
||||
|
||||
المرجع في مشكلة جديدة
حظر مستخدم