|
1 |
| -ActionMailer::Base.smtp_settings = { |
2 |
| - address: ENV['SMTP_SERVER'] || "smtp.gmail.com", |
3 |
| - port: ENV['SMTP_PORT'] || 587, |
4 |
| - domain: ENV['SMTP_DOMAIN'], |
5 |
| - authentication: ENV['SMTP_AUTHENTICATION'] == 'none' ? nil : ENV['SMTP_AUTHENTICATION'] || "plain", |
6 |
| - enable_starttls_auto: ENV['SMTP_ENABLE_STARTTLS_AUTO'] == 'true', |
7 |
| - ssl: ENV['SMTP_SSL'] == 'true', |
8 |
| - user_name: ENV['SMTP_USER_NAME'] == 'none' ? nil : ENV['SMTP_USER_NAME'].presence, |
9 |
| - password: ENV['SMTP_USER_NAME'] == 'none' ? nil : ENV['SMTP_PASSWORD'].presence, |
10 |
| - openssl_verify_mode: ENV['SMTP_OPENSSL_VERIFY_MODE'].presence, |
11 |
| - ca_path: ENV['SMTP_OPENSSL_CA_PATH'].presence, |
12 |
| - ca_file: ENV['SMTP_OPENSSL_CA_FILE'].presence, |
13 |
| - read_timeout: ENV['SMTP_READ_TIMEOUT']&.to_i, |
14 |
| - open_timeout: ENV['SMTP_OPEN_TIMEOUT']&.to_i, |
15 |
| - } |
| 1 | +ActionMailer::Base.smtp_settings = {}.tap { |config| |
| 2 | + config[:address] = ENV['SMTP_SERVER'] || 'smtp.gmail.com' |
| 3 | + config[:port] = ENV['SMTP_PORT']&.to_i || 587 |
| 4 | + config[:domain] = ENV['SMTP_DOMAIN'] |
| 5 | + |
| 6 | + authentication = ENV['SMTP_AUTHENTICATION'].presence || 'plain' |
| 7 | + user_name = ENV['SMTP_USER_NAME'].presence || 'none' |
| 8 | + |
| 9 | + if authentication != 'none' && user_name != 'none' |
| 10 | + config[:authentication] = authentication |
| 11 | + config[:user_name] = user_name |
| 12 | + config[:password] = ENV['SMTP_PASSWORD'].presence |
| 13 | + end |
| 14 | + |
| 15 | + config[:enable_starttls_auto] = ENV['SMTP_ENABLE_STARTTLS_AUTO'] == 'true' |
| 16 | + config[:ssl] = ENV['SMTP_SSL'] == 'true' |
| 17 | + config[:openssl_verify_mode] = ENV['SMTP_OPENSSL_VERIFY_MODE'].presence |
| 18 | + config[:ca_path] = ENV['SMTP_OPENSSL_CA_PATH'].presence |
| 19 | + config[:ca_file] = ENV['SMTP_OPENSSL_CA_FILE'].presence |
| 20 | + config[:read_timeout] = ENV['SMTP_READ_TIMEOUT']&.to_i |
| 21 | + config[:open_timeout] = ENV['SMTP_OPEN_TIMEOUT']&.to_i |
| 22 | +} |
0 commit comments