After a lot of testing, and a lot of help from @thoka, I offer the following summary:
I am able to run SMTP tests using the same creds that I have supplied container/app.yml that work with both swaks (Swaks - Swiss Army Knife for SMTP) and sample Ruby code provide by @thoka (see below).
These work consistently. However, trying to standup a Discourse server (which cannot send the initial email to the admin user) or using discourse-doctor bot result in email failures:
==================== MAIL TEST ====================
For a robust test, get an address from http://www.mail-tester.com/
Or just send a test message to yourself.
Email address for mail test? ('n' to skip) [admin@burlyqna.org]:
Sending mail to admin@burlyqna.org. . .
Testing sending to admin@burlyqna.org using smtp.mailfence.com:465, username:xxx@mailfence.com with plain auth.
SMTP server connection successful.
Sending to admin@burlyqna.org. . .
Sending mail failed.
end of file reached
This seems to be a protocol config failure, as I’m able send test emails using standard Ruby tools:
require 'mail'
SMTP_SERVER = 'smtp.mailfence.com'
SMTP_PORT = 465
USERNAME = 'xyz'
PASSWORD = '...'
FROM = 'admin@burlyqna.org'
TO = 'testing@gmail.com'
SUBJECT = 'Test from Ruby'
BODY = "Hello,\n\nThis is a test email sent from Ruby over a SSL-secured connection.\n\nBest regards!"
Mail.defaults do
delivery_method :smtp, {
address: SMTP_SERVER,
port: SMTP_PORT,
user_name: USERNAME,
password: PASSWORD,
domain: "burlyqna.org",
enable_starttls_auto: :false,
authentication: :plain,
ssl: true,
}
end
begin
puts 'Sending email...'
puts "SMTP_SERVER: #{SMTP_SERVER}"
puts "SMTP_PORT: #{SMTP_PORT}"
puts "USERNAME: #{USERNAME}"
puts "PASSWORD: #{PASSWORD}"
puts "FROM: #{FROM}"
puts "TO: #{TO}"
mail = Mail.new do
to TO
from FROM
subject SUBJECT
body BODY
end
mail.deliver!
end
The current SMTP settings in my app.yml are:
DISCOURSE_SMTP_ADDRESS: smtp.mailfence.com
DISCOURSE_SMTP_PORT: 465
DISCOURSE_SMTP_USER_NAME: xxx@mailfence.com
DISCOURSE_SMTP_PASSWORD: '...'
DISCOURSE_SMTP_FORCE_TLS: true # https://meta.discourse.org/t/cannot-send-email-problem-with-port-465/246004/8
DISCOURSE_SMTP_ENABLE_START_TLS: false # (optional, default true)
DISCOURSE_SMTP_DOMAIN: burlyqna.org # (required by some providers)
DISCOURSE_NOTIFICATION_EMAIL: noreply@talk.burlyqna.org