wpballa1
Posts: 70
Joined: Sat Jun 27, 2015 12:49 am

No heirloom-mailx with Buster?

Sat Sep 14, 2019 4:19 pm

I usually use heirloom-mailx and ssmtp to send messages with software under Stretch, but when trying to install heirloom-mailx on a Buster Pi, I get the message that there is no install candidate. Does anyone have a workaround for this?

Code: Select all

pi@B4:~ $ sudo apt-get install heirloom-mailx
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Package heirloom-mailx is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'heirloom-mailx' has no installation candidate

trejan
Posts: 2082
Joined: Tue Jul 02, 2019 2:28 pm

Re: No heirloom-mailx with Buster?

Sat Sep 14, 2019 4:32 pm

The transitional heirloom-mailx package was removed. Use s-nail directly as all heirloom-mailx did was install s-nail + a symlink. If you don't want to update your scripts then create the symlink yourself.

trevmlt
Posts: 2
Joined: Mon Apr 09, 2018 7:17 pm

Re: No heirloom-mailx with Buster?

Wed May 06, 2020 4:59 am

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

Also,
$ echo "this is a test" | s-nail -v -s "Subject" my.email@gmail.com

but this script will not send an email.

Code: Select all

class Email:
    """Class to send emails"""

    def __init__(self):
        self.logger = logging.getLogger(__name__)

    def send_email(self, recipient, subject, msg):
        """Sends an email to the specified email address.

        Args:
            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

        try:
            mail = smtplib.SMTP(cfg.SMTP_SERVER, cfg.SMTP_PORT)
            if cfg.SMTP_USER != '' and cfg.SMTP_PASS != '':
                mail.login(cfg.SMTP_USER, cfg.SMTP_PASS)
            mail.sendmail(cfg.EMAIL_FROM, recipient, msg.as_string())
            mail.quit()
        except:
            self.logger.error("Exception sending email: %s", sys.exc_info()[0])

wpballa1
Posts: 70
Joined: Sat Jun 27, 2015 12:49 am

Re: No heirloom-mailx with Buster?

Tue May 12, 2020 6:09 pm

You need to set up the mailer initialization in your home folder. Below is a typical initialization for gmail accounts.

nano .mailrc

Code: Select all

set smtp-use-starttls
set ssl-verify=ignore
set smtp=smtp://smtp.gmail.com:587
set smtp-auth=login
set smtp-auth-user="yourmail@gmail.com"
set smtp-auth-password="yourpassword"
set from=”wherever <yourmail@gmail.com>”
set sendwait
set ssl-protocol=-ALL+TLSv1.2
Then the s-nail command ought to work.

Return to “Troubleshooting”