مراية لـ
https://github.com/postalserver/postal.git
تم المزامنة 2025-12-01 05:43:04 +00:00
feat: support for configuring postal with environment variables
هذا الالتزام موجود في:
@@ -5,126 +5,122 @@
|
|||||||
# You can refer to this for a complete listing all available configuration options.
|
# You can refer to this for a complete listing all available configuration options.
|
||||||
|
|
||||||
web:
|
web:
|
||||||
host: postal.example.com
|
host: <%= ENV.fetch('POSTAL_HOST', 'postal.example.com') %>
|
||||||
protocol: https
|
protocol: <%= ENV.fetch('POSTAL_PROTOCOL', 'https') %>
|
||||||
|
|
||||||
general:
|
general:
|
||||||
use_ip_pools: false
|
use_ip_pools: <%= ENV.fetch('POSTAL_USE_IP_POOLS', 'false') %>
|
||||||
exception_url:
|
exception_url: <%= ENV.fetch('POSTAL_EXCEPTION_URL', '') %>
|
||||||
maximum_delivery_attempts: 18
|
maximum_delivery_attempts: <%= ENV.fetch('POSTAL_MAXIMUM_DELIVERY_ATTEMPTS', '18') %>
|
||||||
maximum_hold_expiry_days: 7
|
maximum_hold_expiry_days: <%= ENV.fetch('POSTAL_MAXIMUM_HOLD_EXPIRY_DAYS', '7') %>
|
||||||
suppression_list_removal_delay: 30
|
suppression_list_removal_delay: <%= ENV.fetch('POSTAL_SUPPRESSION_LIST_REMOVAL_DELAY', '30') %>
|
||||||
use_local_ns_for_domains: false
|
use_local_ns_for_domains: <%= ENV.fetch('POSTAL_USE_LOCAL_NS_FOR_DOMAINS', 'false') %>
|
||||||
default_spam_threshold: 5.0
|
default_spam_threshold: <%= ENV.fetch('POSTAL_DEFAULT_SPAM_THRESHOLD', '5.0') %>
|
||||||
default_spam_failure_threshold: 20.0
|
default_spam_failure_threshold: <%= ENV.fetch('POSTAL_DEFAULT_SPAM_FAILURE_THRESHOLD', '20.0') %>
|
||||||
use_resent_sender_header: true
|
use_resent_sender_header: <%= ENV.fetch('POSTAL_USE_RESENT_SENDER_HEADER', 'true') %>
|
||||||
|
|
||||||
web_server:
|
web_server:
|
||||||
bind_address: 127.0.0.1
|
bind_address: <%= ENV.fetch('WEB_SERVER_BIND_ADDRESS', '0.0.0.0') %>
|
||||||
port: 5000
|
port: <%= ENV.fetch('WEB_SERVER_PORT', '5000') %>
|
||||||
max_threads: 5
|
max_threads: <%= ENV.fetch('WEB_SERVER_MAX_THREADS', '5') %>
|
||||||
|
|
||||||
main_db:
|
main_db:
|
||||||
host: 127.0.0.1
|
host: <%= ENV.fetch('MAIN_DB_HOST', '127.0.0.1') %>
|
||||||
port: 3306
|
port: <%= ENV.fetch('MAIN_DB_PORT', '3306') %>
|
||||||
username: postal
|
username: <%= ENV.fetch('MAIN_DB_USERNAME', 'postal') %>
|
||||||
password:
|
password: <%= ENV.fetch('MAIN_DB_PASSWORD', '') %>
|
||||||
database: postal
|
database: <%= ENV.fetch('MAIN_DB_DATABASE', 'postal') %>
|
||||||
pool_size: 5
|
pool_size: <%= ENV.fetch('MAIN_DB_POOL_SIZE', '5') %>
|
||||||
|
|
||||||
logging:
|
|
||||||
stdout: false
|
|
||||||
root: # Automatically determined based on config root
|
|
||||||
max_log_file_size: 20
|
|
||||||
max_log_files: 10
|
|
||||||
graylog:
|
|
||||||
host:
|
|
||||||
port: 12201
|
|
||||||
|
|
||||||
message_db:
|
message_db:
|
||||||
host: 127.0.0.1
|
host: <%= ENV.fetch('MESSAGE_DB_HOST', '127.0.0.1') %>
|
||||||
port: 3306
|
port: <%= ENV.fetch('MESSAGE_DB_PORT', '3306') %>
|
||||||
username: postal
|
username: <%= ENV.fetch('MESSAGE_DB_USERNAME', 'postal') %>
|
||||||
password:
|
password: <%= ENV.fetch('MESSAGE_DB_PASSWORD', '') %>
|
||||||
prefix: postal
|
prefix: <%= ENV.fetch('MESSAGE_DB_PREFIX', 'postal') %>
|
||||||
|
|
||||||
rabbitmq:
|
rabbitmq:
|
||||||
host: 127.0.0.1
|
host: <%= ENV.fetch('RABBITMQ_HOST', '127.0.0.1') %>
|
||||||
port: 5672
|
port: <%= ENV.fetch('RABBITMQ_PORT', '5672') %>
|
||||||
tls: false
|
username: <%= ENV.fetch('RABBITMQ_USERNAME', 'postal') %>
|
||||||
verify_peer: true
|
password: <%= ENV.fetch('RABBITMQ_PASSWORD', '') %>
|
||||||
tls_ca_certificates:
|
vhost: <%= ENV.fetch('RABBITMQ_VHOST', '/postal') %>
|
||||||
- /etc/ssl/certs/ca-certificates.crt
|
tls: <%= ENV.fetch('RABBITMQ_TLS', 'false') %>
|
||||||
username: postal
|
verify_peer: <%= ENV.fetch('RABBITMQ_VERIFY_PEER', 'true') %>
|
||||||
password:
|
tls_ca_certificates: <%= ENV.fetch('RABBITMQ_TLS_CA_CERTIFICATES', '/etc/ssl/certs/ca-certificates.crt'.split(',').inspect) %>
|
||||||
vhost: /postal
|
|
||||||
|
logging:
|
||||||
|
stdout: <%= ENV.fetch('LOGGING_STDOUT', 'false') %>
|
||||||
|
root: <%= ENV.fetch('LOGGING_ROOT', '') %>
|
||||||
|
max_log_file_size: <%= ENV.fetch('LOGGING_MAX_LOG_FILES', '20') %>
|
||||||
|
max_log_files: <%= ENV.fetch('LOGGING_MAX_LOG_FILES', '10') %>
|
||||||
|
graylog:
|
||||||
|
host: <%= ENV.fetch('GRAYLOG_HOST', '') %>
|
||||||
|
port: <%= ENV.fetch('GRAYLOG_PORT', '12201') %>
|
||||||
|
|
||||||
workers:
|
workers:
|
||||||
quantity: 1
|
threads: <%= ENV.fetch('WORKER_THREADS', '4') %>
|
||||||
threads: 4
|
|
||||||
|
|
||||||
smtp_server:
|
smtp_server:
|
||||||
port: 25
|
port: <%= ENV.fetch('SMTP_SERVER_PORT', '25') %>
|
||||||
bind_address: '::'
|
bind_address: "<%= ENV.fetch('SMTP_SERVER_BIND_ADDRESS', '::') %>"
|
||||||
tls_enabled: false
|
tls_enabled: <%= ENV.fetch('SMTP_SERVER_TLS_ENABLED', 'false') %>
|
||||||
tls_certificate_path: # Defaults to config/smtp.cert
|
tls_certificate_path: <%= ENV.fetch('SMTP_SERVER_TLS_CERTIFICATE_PATH', '') %> # Defaults to config/smtp.cert
|
||||||
tls_private_key_path: # Defaults to config/smtp.key
|
tls_private_key_path: <%= ENV.fetch('SMTP_SERVER_TLS_PRIVATE_KEY_PATH', '') %> # Defaults to config/smtp.key
|
||||||
tls_ciphers:
|
tls_ciphers: <%= ENV.fetch('SMTP_SERVER_TLS_CIPHERS', '') %>
|
||||||
ssl_version: SSLv23
|
ssl_version: <%= ENV.fetch('SMTP_SERVER_SSL_VERSION', 'SSLv23') %>
|
||||||
proxy_protocol: false
|
proxy_protocol: <%= ENV.fetch('SMTP_SERVER_PROXY_PROTOCOL', 'false') %>
|
||||||
log_connect: true
|
log_connect: <%= ENV.fetch('SMTP_SERVER_LOG_CONNECT', 'false') %>
|
||||||
strip_received_headers: false
|
strip_received_headers: <%= ENV.fetch('SMTP_SERVER_STRIP_RECEIVED_HEADERS', 'false') %>
|
||||||
max_message_size: 14 # size in Megabytes
|
max_message_size: <%= ENV.fetch('SMTP_SERVER_MAX_MESSAGE_SIZE', '14') %> # size in Megabytes
|
||||||
|
|
||||||
smtp_relays:
|
smtp_relays:
|
||||||
-
|
- hostname:
|
||||||
hostname:
|
|
||||||
port: 25
|
port: 25
|
||||||
ssl_mode: Auto
|
ssl_mode: Auto
|
||||||
|
|
||||||
dns:
|
dns:
|
||||||
mx_records:
|
mx_records: <%= ENV.fetch('DNS_MX_RECORDS', 'mx.postal.example.com'.split(',').inspect) %>
|
||||||
- mx.postal.example.com
|
smtp_server_hostname: <%= ENV.fetch('DNS_SMTP_SERVER_HOSTNAME', 'postal.example.com') %>
|
||||||
smtp_server_hostname: postal.example.com
|
spf_include: <%= ENV.fetch('DNS_SPF_INCLUDE', 'spf.postal.example.com') %>
|
||||||
spf_include: spf.postal.example.com
|
return_path: <%= ENV.fetch('DNS_RETURN_PATH', 'rp.postal.example.com') %>
|
||||||
return_path: rp.postal.example.com
|
route_domain: <%= ENV.fetch('DNS_ROUTE_DOMAIN', 'routes.postal.example.com') %>
|
||||||
route_domain: routes.postal.example.com
|
track_domain: <%= ENV.fetch('DNS_TRACK_DOMAIN', 'track.postal.example.com') %>
|
||||||
track_domain: track.postal.example.com
|
helo_hostname: <%= ENV.fetch('DNS_HELO_HOSTNAME', '') %> # By default, this will be the same as the `smtp_server_hostname`
|
||||||
helo_hostname: # By default, this will be the same as the `smtp_server_hostname`
|
dkim_identifier: <%= ENV.fetch('DNS_DKIM_IDENTIFIER', 'postal') %>
|
||||||
dkim_identifier: postal
|
domain_verify_prefix: <%= ENV.fetch('DNS_DOMAIN_VERIFY_PREFIX', 'postal-verification') %>
|
||||||
domain_verify_prefix: postal-verification
|
custom_return_path_prefix: <%= ENV.fetch('DNS_CUSTOM_RETURN_PATH_PREFIX', 'psrp') %>
|
||||||
custom_return_path_prefix: psrp
|
|
||||||
|
|
||||||
smtp:
|
smtp:
|
||||||
host: 127.0.0.1
|
host: <%= ENV.fetch('SMTP_HOST', '127.0.0.1') %>
|
||||||
port: 25
|
port: <%= ENV.fetch('SMTP_PORT', '25') %>
|
||||||
username: # Complete when Postal is running and you can
|
username: <%= ENV.fetch('SMTP_USERNAME', '') %> # Complete when Postal is running and you can
|
||||||
password: # generate the credentials within the interface.
|
password: <%= ENV.fetch('SMTP_PASSWORD', '') %> # generate the credentials within the interface.
|
||||||
from_name: Postal
|
from_name: <%= ENV.fetch('SMTP_FROM_NAME', 'Postal') %>
|
||||||
from_address: postal@yourdomain.com
|
from_address: <%= ENV.fetch('SMTP_FROM_ADDRESS', 'postal@example.com') %>
|
||||||
|
|
||||||
rails:
|
rails:
|
||||||
environment: production
|
environment: <%= ENV.fetch('RAILS_ENV', 'production') %>
|
||||||
secret_key:
|
secret_key: <%= ENV.fetch('RAILS_SECRET_KEY_BASE', '') %>
|
||||||
|
|
||||||
rspamd:
|
rspamd:
|
||||||
enabled: false
|
enabled: <%= ENV.fetch('RSPAMD_ENABLED', 'false') %>
|
||||||
host: 127.0.0.1
|
host: <%= ENV.fetch('RSPAMD_HOST', '127.0.0.1') %>
|
||||||
port: 11334
|
port: <%= ENV.fetch('RSPAMD_PORT', '11334') %>
|
||||||
ssl: false
|
ssl: <%= ENV.fetch('RSPAMD_SSL', 'false') %>
|
||||||
password: null
|
password: <%= ENV.fetch('RSPAMD_PASSWORD', '') %>
|
||||||
flags: null
|
flags: <%= ENV.fetch('RSPAMD_FLAGS', '') %>
|
||||||
|
|
||||||
spamd:
|
spamd:
|
||||||
enabled: false
|
enabled: <%= ENV.fetch('SPAMD_ENABLED', 'false') %>
|
||||||
host: 127.0.0.1
|
host: <%= ENV.fetch('SPAMD_HOST', '127.0.0.1') %>
|
||||||
port: 783
|
port: <%= ENV.fetch('SPAMD_PORT', '783') %>
|
||||||
|
|
||||||
clamav:
|
clamav:
|
||||||
enabled: false
|
enabled: <%= ENV.fetch('CLAMAV_ENABLED', 'false') %>
|
||||||
host: 127.0.0.1
|
host: <%= ENV.fetch('CLAMAV_HOST', '127.0.0.1') %>
|
||||||
port: 2000
|
port: <%= ENV.fetch('CLAMAV_PORT', '2000') %>
|
||||||
|
|
||||||
smtp_client:
|
smtp_client:
|
||||||
open_timeout: 30
|
open_timeout: <%= ENV.fetch('SMTP_CLIENT_OPEN_TIMEOUT', '30') %>
|
||||||
read_timeout: 60
|
read_timeout: <%= ENV.fetch('SMTP_CLIENT_READ_TIMEOUT', '60') %>
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
require "erb"
|
||||||
require "yaml"
|
require "yaml"
|
||||||
require "pathname"
|
require "pathname"
|
||||||
require "cgi"
|
require "cgi"
|
||||||
@@ -78,7 +79,11 @@ module Postal
|
|||||||
end
|
end
|
||||||
|
|
||||||
def self.defaults
|
def self.defaults
|
||||||
@defaults ||= YAML.load_file(defaults_file_path)
|
@defaults ||= begin
|
||||||
|
file = File.read(defaults_file_path)
|
||||||
|
yaml = ERB.new(file).result
|
||||||
|
YAML.safe_load(yaml)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.database_url
|
def self.database_url
|
||||||
|
|||||||
المرجع في مشكلة جديدة
حظر مستخدم