Skip to content

Instantly share code, notes, and snippets.

@smoser
Created May 18, 2020 15:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save smoser/a9bac43763552dda6e6b9edcc7228026 to your computer and use it in GitHub Desktop.
Save smoser/a9bac43763552dda6e6b9edcc7228026 to your computer and use it in GitHub Desktop.
ubuntu email setup through dreamhost relay with msmtp

usage of msmtp for email relay through dreamhost

I just needed the sendmail cli interface to work for things like bts or the occasional sending of an email.

msmtp seems like a good solution.

Heres what I did to get it functional

  • install mtsmtp-mta

    sudo apt-get install msmtp-mta
    
  • configure client

    I have only configured per-user, not site-wide. (so only my user can send mail, not 'root' or others). You can do that, I just haven't.

    See the .msmtprc file below.

links

# https://marlam.de/msmtp/msmtp.html#A-user-configuration-file
# this is my ~/.msmtprc
defaults
port 587
tls on
account primary
# https://help.dreamhost.com/hc/en-us/articles/215612887-Email-client-protocols-and-port-numbers
# Host name of the SMTP server
host smtp.dreamhost.com
# Envelope-from address
from Scott Moser <me@my-email.net>
# Authentication. The password is plaintext here. I have a "relay only" account
# that can send mail and has a tiny receive quota. You can send mail from
# other addresses using that address
auth on
user relay@my-email.net
password SECRET
account default : primary
#!/bin/sh
# just a simple test of using sendmail.
# call it with: test-sendmail.sh [to [from]]
to=${1:-me@my-email.net}
from=${2:-}
cmd=${CMD:-sendmail -vt}
$cmd <<ENDEND
To: ${to}
Subject: Testing that sendmail works. sent $(date +%H:%M)
${from:+From: $from}
I just wanted to see if this works.
testing using msmtp
Here I did not use the And here goes the e-mail body, test test test..
to=$to
from=$from
ENDEND
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment