Test email setup before the installation is started

The discourse-doctor tool can send a test email. This should also be added to the discourse-setup tool. Do a quick email test to verify that the SMTP data that the user entered works BEFORE setting up the whole software stack. As the notes state, it will be inoperative if email isn’t setup right.

This could save a lot of time if the person doing the installation typed even on piece of data in incorrectly.

Hmm. It looks like it’s possible to do an only semi-braindead SMTP test like this:

echo Hello world > /tmp/mail.txt
curl -v  smtp://$DISCOURSE_SMTP_ADDRESS:$DISCOURSE_SMTP_PORT  \
  --mail-from noreply@$DISCOURSE_HOSTNAME \
  --mail-rcpt $(echo $DISCOURSE_DEVELOPER_EMAILS | cut -d ',' -f 1) \
  --user $DISCOURSE_SMTP_USER_NAME:"$DISCOURSE_SMTP_PASSWORD" \
  --upload-file /tmp/mail.txt 

So it should be possible to do such a test. My concern is that it would have a bunch of false positives and false negatives, but maybe printing a warning if it fails could help some people.

Maybe a better idea would be yet another script (discourse-mail-check?) that would do a quick and dirty test like that if you’re having trouble.

I was just hoping to have the test directly after the user enters the SMTP details. So it sends a test email to an address the user provides and the user is asked if they received the email, if they did, the installation continues. If they did not they can re-test or alter SMTP config and try again.

2 Likes

as described in my post here Install Discourse on Amazon Web Services (AWS) with Lightsail, SES, and Route 53 - #4 by wal I was able to send test emails prior to running the full discourse-setup script using this method described here with telnet

notably, I used port 587 instead of 25 shown there, and you need to be sure to base64 encode your SMTP username and password.

Also linked in that post is a script that AWS provides which shows how to do the same with the openssl command (link here; Creating configuration sets in SES - Amazon Simple Email Service )

if you are not using AWS SES for your email server you may have to tweak the script a little but in general I think one or both of these should be helpful for you to verify email before the installation (this is what I did)

while I agree that there should ideally be a way to test the email prior to installation, I think it may actually be preferable to have it shipped as a separate stand-alone script of some sort with Discourse so that you can run it without having to go through the entire setup process, which can take ~10min

1 Like