Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

MTA for Perl

by Bod (Parson)
on Mar 18, 2024 at 20:51 UTC ( [id://11158348]=perlquestion: print w/replies, xml ) Need Help??

Bod has asked for the wisdom of the Perl Monks concerning the following question:

I need to install a Mail Transfer Agent that will be used with MIME::Lite

I understand that the modern choices are Postfix or Exim. However, MIME::Lite says it uses sendmail which is pretty old isn't it?

I have never looked at MTA's before so any advice would be appreciated. This is being installed on a RaspberryPi. Does the MTA only deal with outgoing mail or will it manage incoming mail as well? If not, what do I need for that?

Replies are listed 'Best First'.
Re: MTA for Perl
by philipbailey (Curate) on Mar 18, 2024 at 23:46 UTC

    I'm assuming you are using Linux or Unix. My take is that any of Sendmail, Exim or Postfix are fine as MTAs and as a starting point would consider whichever is a default on your OS or distro, as it's more likely to have a good basic setup out of the box. I've used all 3 at various times. My perception is that as any of these MTAs is more than sufficiently performant for common use cases, the complexity of configuration is a big deciding factor if you are considering choosing a non-default MTA for your OS.

    Sendmail, the oldest widely-used MTA, has a notoriously opaque low-level config file, though there are some higher level abstractions available; I therefore rank Sendmail as worst for configuration complexity. When Postfix was supplied with a new (to us) OS version some years ago, I rather fell in love with the comparative simplicity and power of its configuration and so now use Postfix personally, whenever I have a choice. Exim has an intermediate level of difficulty.

    So what about MIME::Lite and its use of "sendmail". Well, it so happens that both Exim and Postfix come with a "sendmail" command as standard, which mimics at least the core functionality of Sendmail's CLI. MIME::Lite looks in /usr/bin/sendmail, /usr/sbin/sendmail and then for a sendmail command in your PATH. So it's likely to work just fine with any of these MTAs without any work. I'll leave the question (also mentioned by 1nickt) of whether to use MIME::Lite given the statement these days in its documentation that it's no longer recommended (though I have used it without problem in years gone by).

      I'm assuming you are using Linux or Unix. My take is that any of Sendmail, Exim or Postfix are fine as MTAs and as a starting point would consider whichever is a default on your OS or distro, as it's more likely to have a good basic setup out of the box.

      Yes - it's Linux

      It's a Raspberry Pi which doesn't come with an MTA as default. Hence why I need to make a choice. I'm also treating it as a learning experience. This isn't mission critical so a few mistakes along the way won't hurt and will increase my knowledge 🙂

      Well, it so happens that both Exim and Postfix come with a "sendmail" command as standard...

      Oh! That's helpful information - thank you.

      Given everything I now know, Postfix will be the MTA of choice.

        Adding a bit to that, the real question is how you want the mail to flow. An MTA like Postfix will manage its own queue, so your program writes out a mail message and gets "success" that it has been delivered to Postfix. If Postfix has a problem delivering it, you'll need separate monitoring to find out about that, and meanwhile the messages will pile up in the queue on the raspberry Pi. The other way is to deliver mail directly from your app to some external SMTP host, like a relay service from your internet provider, or SendGrid, or something like that. If you can't push the message to them, the error can be handled and reported in the application. This also saves you the hassle of setting up an MTA, which is nice, unless your whole goal was to learn about MTAs.
Re: MTA for Perl
by GrandFather (Saint) on Mar 18, 2024 at 21:47 UTC

    Does Sending help? In the past SMTP has been my friend, although I've mostly a Windows user so YMMV with that, but it looks like anything that can be command line driven ought to work.

    Update: fixed link

    Optimising for fewest key strokes only makes sense transmitting to Pluto or beyond
      Does Sending help

      Thank you...

      So, it appears I need to either install sendmail to use MIME::Lite or I need to change the configuration of MIME::Lite

      That begs the question - is sendmail still relevant...if so, why were Postfix and Exim and probably others, developed?

Re: MTA for Perl
by afoken (Chancellor) on Mar 19, 2024 at 10:46 UTC
    MIME::Lite says it uses sendmail

    ... or SMTP, as explained by GrandFather in Re: MTA for Perl.

    But: sendmail (the executable) is not always Sendmail (the mail server). Yes, Sendmail is old (and has a long list of security problems), and in fact it is so old that its main executable sendmail has become a de facto standard. That is why many other mail servers come with a sendmail command that works as a drop-in replacement for the real sendmail from Sendmail. Usually, the replacement does not implement all commands and options, but only as much as needed to get mails sent out. The replacement sendmail is either a dedicated helper, or it is just a symlink to the main executable.

    I think that Nullmailer is a very useful package if you already have a working mailserver, either locally or at your provider, and need a working mail system on a local machine. It just delegates EVERYTHING to that working mailserver ("smarthost") except for collecting mails that will be passed to the smarthost for delivery. I use it a lot on several virtual machines to connect to the "real" mailserver in the network.

    Alexander

    (Changed wording a few times in the first few minutes after posting.)

    --
    Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
Re: MTA for Perl
by 1nickt (Canon) on Mar 18, 2024 at 21:13 UTC

    I'm a little surprised you continue to use MIME::Lite given your high standards and the warning in that module's doc:

    WAIT!

    MIME::Lite is not recommended by its current maintainer. There are a number of alternatives, like Email::MIME or MIME::Entity and Email::Sender, which you should probably use instead. MIME::Lite continues to accrue weird bug reports, and it is not receiving a large amount of refactoring due to the availability of better alternatives. Please consider using something else.


    The way forward always starts with a minimal test.
      I'm a little surprised you continue to use MIME::Lite given your high standards and the warning in that module's doc

      I have a legacy module that I want to use because it does everything I need to do but it uses MIME::Lite. I would rather not rewrite it...

      Plus, quite some time ago I suggested moving away from MIME::Lite and Corion chipped in...I figured that if a module is good enough for a Monk who is vastly more knowledgable and more experienced than me, then that's good enough reason for me not to change existing code even if I plan to avoid it in future. See Re^3: printing output of a perl script to the Email body

      Generally, I don't use any (publically available) Perl module to send email. I use the Brevo API instead.

        To qualify that a bit, MIME::Lite still works well for sending. If I were starting out with a fresh project where sending mail is a core functionality, I would maybe also look at Email::Sender or one of the other modules. But in my case, sending mail is usually a requirement that requires little beyond sending an HTML and/or text mail with some files attached, and that is well implemented by MIME::Lite. Usually not even the recipient mail addresses are supplied by the user, so the inputs are fairly trusted and the scripts also only talk to my MTA for handing off the mail and later forwarding.

Re: MTA for Perl
by stevieb (Canon) on Mar 19, 2024 at 07:28 UTC
    I have never looked at MTA's before

    If you're being asked or you are presently required to look at outbound email delivery I suggest you do a deep delve. Since ~1998 when I first became attached to email delivery, things have changed so much that to send an email, you need to be an expert, or have an expert on staff.

    Does the MTA only deal with outgoing mail or will it manage incoming mail as well?

    A Mail Transport Agent (MTA) performs outbound email responsibilities only. It transports an email from one system to another (it does deal with incoming mail, only enough to re-transport it... this would be classified as a "relay"); enough said.

    A Mail Delivery Agent (MDA) is responsible for figuring out how to deliver a message to a recipient. Many MTAs include the separate capabilities of MDAs.

    Go with Postfix. I can say this from email delivery experience, and as an expert on work with the Raspberry Pi.

      If you're being asked or you are presently required to look at outbound email delivery I suggest you do a deep delve. Since ~1998 when I first became attached to email delivery, things have changed so much that to send an email, you need to be an expert, or have an expert on staff.

      Oh no...I am not getting in evolved in serious mail delivery. This is just for notification emails, mostly being sent to me.

      I know enough about email to know that ensuring consistent delivery and reputation can be a full-time job. That's why I use Brevo for all our outgoing emails. Mostly I pass email to them through their API but I do use their SMTP server as well and the deliverability is much better than I could achieve trying to manage everything.

      This is a "fun project" as much about learning as the final result. I know my knowledge of email is very limited and this is an opportunity to change that 🙂

      A Mail Transport Agent (MTA) performs outbound email responsibilities only...A Mail Delivery Agent (MDA) is responsible for figuring out how to deliver a message to a recipient

      Thanks - that's very helpful 👍

      So, if I wanted to handle incoming mail with a number of IMAP mailboxes on a Raspberry Pi/Linux box, what would I need to use for that? I have no plans to do this right now but knowing will be very useful in my quest to develop a better understanding of email infrastructure and best practice.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://11158348]
Approved by GrandFather
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (3)
As of 2025-06-20 16:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.