Page 1 of 1

No heirloom-mailx with Buster?

Posted: Sat Sep 14, 2019 4:19 pm
by wpballa1
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

Re: No heirloom-mailx with Buster?

Posted: Sat Sep 14, 2019 4:32 pm
by trejan
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.

Re: No heirloom-mailx with Buster?

Posted: Wed May 06, 2020 4:59 am
by trevmlt
Can someone PLEASE expand on 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, 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"

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.

            recipient: Email address to send to.
            subject: Email subject.
            msg: Body of email to send.
        """"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.login(cfg.SMTP_USER, cfg.SMTP_PASS)
            mail.sendmail(cfg.EMAIL_FROM, recipient, msg.as_string())
            self.logger.error("Exception sending email: %s", sys.exc_info()[0])

Re: No heirloom-mailx with Buster?

Posted: Tue May 12, 2020 6:09 pm
by wpballa1
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://
set smtp-auth=login
set smtp-auth-user=""
set smtp-auth-password="yourpassword"
set from=”wherever <>”
set sendwait
set ssl-protocol=-ALL+TLSv1.2
Then the s-nail command ought to work.