Setup smtp on your Mac and send mail from the command line

Install msmtp and create a directory which will hold the ssl-certificates.

brew install msmtp
mkdir -p ~/Dropbox/Public/ssl-certs

Create a system-wide config-file in /usr/local/Cellar/msmtp/1.6.6/etc/msmtprc

#file /usr/local/Cellar/msmtp/1.6.6/etc/msmtprc

# Begin msmtprc 
# Set default values for all following accounts.
defaults
tls on
logfile ~/.msmtp.log

# A first gmail address
account example@gmail.com
host smtp.gmail.com
port 587
protocol smtp
auth on
from example@gmail.com
user example@gmail.com
tls on
tls_starttls on

# this next line is crucial: you have to point to the correct security certificate for GMail. 
# If this doesn't work, check the mstmp documentation
# at http://msmtp.sourceforge.net/documentation.html for help
#
# This next line should all be on one long line:
tls_trust_file ~/Dropbox/Public/thawte_certs/thawte_Primary_Root_CA.pem

# Set a default account
# You need to set a default account for Mail
account default : example@gmail.com

# end msmtprc

Set up to use msmtp

echo set sendmail="/usr/local/bin/msmtp" > ~/.mailrc

Save your Gmail password in your keychain:

  1. open Keychain Access application on mac
  2. create new password item: File > New Password Item
  3. Keychain Item Name: smtp://smtp.gmail.com
  4. Account Name (exactly as used in msmtprc): <address>@gmail.com
  5. Password: <gmail_password>

Click Here to Leave a Comment Below

Automatisch bestanden verwerken en mailen met Hazel - Paul Edenburg - 16/09/2018

[…] NB: Kijk dan of je mail ook daadwerkelijk binnenkomt in je mailbox. Zo niet, installeer dan het programma msmtp. […]

Reply
Leave a Reply: