Can someone PLEASE expand on this...how exactly does one create a suitable symlink or update your script?
Below is a script I have that when using heirloom-mailx in stretch worked a treat (would send email), but with s-nail installed in Buster it does not. I tried just changing "mail" to "s-nail" out of desperation, but that did not work - HELP.
I use Exim configured to use smtp.gmail.com, and I can send an email using the following line when SSH on my raspberry so I am sure Exim is configured properly and s-nail is working.
After installing s-nail i did the following (I think this is a symlink) because it was done on stretch was done with heirloom-mailx
sudo rm /etc/alternatives/mail
sudo ln -s /usr/bin/s-nail /etc/alternatives/mail
$ echo "this is a test" | s-nail -v -s "Subject" email@example.com
but this script will not send an email.
Code: Select all
"""Class to send emails"""
self.logger = logging.getLogger(__name__)
def send_email(self, recipient, subject, msg):
"""Sends an email to the specified email address.
recipient: Email address to send to.
subject: Email subject.
msg: Body of email to send.
self.logger.info("Sending email to %s: subject = \"%s\", message = \"%s\"", recipient, subject, msg)
msg = MIMEText(msg)
msg['Subject'] = subject
msg['To'] = recipient
msg['From'] = cfg.EMAIL_FROM
msg['X-Priority'] = cfg.EMAIL_PRIORITY
mail = smtplib.SMTP(cfg.SMTP_SERVER, cfg.SMTP_PORT)
if cfg.SMTP_USER != '' and cfg.SMTP_PASS != '':
mail.sendmail(cfg.EMAIL_FROM, recipient, msg.as_string())
self.logger.error("Exception sending email: %s", sys.exc_info())