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.

1 Like