Skip to content

Debugging email sending

In case email sending doesn’t work. Start with this little script to verify if your credentials and SMTP server configuration is actually proper.

Terminal window
# Replace with SMTP user login
USER=support@pro6pp.nl
# Replace with SMTP user login (or another email if you user is allowed to impersonate it)
FROM=support@pro6pp.nl
# SMTP password
SMTP_PASS=somepass
# SMTP server hostname
SERVER=sandbox.smtp.mailtrap.io
# The SMTP port
SMTP_PORT=2525
# The e-mail address to send the test email to, replace with your email to actually receive it
DEST_EMAIL=kvdb@kvdb.net
tee mail.txt <<EOF
From: Kees <$FROM>
To: Kees <$DEST_EMAIL>
Subject: Zomaar even
Date: $(date -R)
Message-Id: <$(date +%s).${FROM}>
Hi,
Just an email
EOF
curl --ssl-reqd -vk smtp://$SERVER:$SMTP_PORT/ \
--mail-from $FROM\
--mail-rcpt $DEST_EMAIL\
--upload-file mail.txt\
--user "$USER:$SMTP_PASS"