I’m looking for a simple sendmail replacement to receive local mail, such as from cron and service failures and forward it to on to a real SMTP server.
I have used msmtpd
successfully but thought I’d ask if folks have other solutions they like.
Submitted 7 months ago by markstos@lemmy.world to selfhosted@lemmy.world
I’m looking for a simple sendmail replacement to receive local mail, such as from cron and service failures and forward it to on to a real SMTP server.
I have used msmtpd
successfully but thought I’d ask if folks have other solutions they like.
ssmtp is what I’ve used before.
@atzanteol @markstos@lemmy.world
ssmtp is unmaintained.
msmtp is the recommended successor. The Arch wiki recommends also considering OpenSMTPD, which I haven't looked at yet.
I just started using OpenSMTPD as a backup relay and it seems to work for that. Very lightweight and easy to set up.
Ah, thanks
ssmtp is also my go-to for this. Or dma (DragonFly Mail Agent) if available.
I use ssmtp as well for a simple sendmail replacement. It takes over the sendmail command, doesn’t open any ports. You configure it for the domain you want and tell it what server to send everything to and it works.
msmtp
never failed me
The one problem with msmtp is that it doesn’t rewrite headers, like “From: root / To: root”. These are not required for SMTP, but they are required by some mail providers who will reject email that doesn’t have an “@” sign in these headers. The author or msmtp has said he does not plan to add this feature.
I worked around the issue with my own sendmail wrapper that rewrites local addresses in From and To headers before passing the message to msmtp. Someone else posted such a script in this bug report:
You can definitely replace senders with correct mail addresses for relaying through SMTP server that expect them (this is what I do):
# /etc/msmtprc account default ... # Replace local recipients with addresses in the aliases file aliases /etc/aliases
# /etc/aliases mailer-daemon: postmaster postmaster: root nobody: root hostmaster: root usenet: root news: root webmaster: root www: root ftp: root abuse: root noc: root security: root root: default www-data: root default: myaddress@gmail.com
After testing ssmtp, nullmailer, and msmtp for relay-only outgoing mail on Fedora #Linux. Here's my final report:
- ssmtp is packaged for Fedora and I got it working, but the Ansible role I found for it had been abandoned by the author because ssmtp itself is unmaintained.
- nullmailer might have worked, but is not packaged for Fedora.
- msmtp worked. I used this Ansible role, after patching it to work on Fedora: https://github.com/chriswayg/ansible-msmtp-mailer
You want an SMTP relay. You can use a free public SMTP relay, or make one yourself. If you make one yourself, don’t keep it open, or spammers will abuse it. If you’re sending mail properly, you’ll need to add it to your SPF entry in your DNS. If you’re just sending mail for yourself, you should be able to set up a filter in your email provider so that it doesn’t get rejected.
I have an SMTP server. I need a sendmail binary that does one thing well: send the message to the SMTP server.
Can’t you use sendmail? Also, check out my updated message above. You’ll need to make sure you can send outbound traffic on port 25.
Use a postfix satellite setup. Requires minimal config and provides queues/retries/etc.
Tried that. Yes, it has the feature I need. But it has a rather complex feature set and documentation when I just need to to send my mail to an SMTP server. I ran into problems configuring it for this in the past which were difficult to diagnose due to the volume of config options and docs. That’s what led me to explore tools that had only the features I needed and no more, like msmtp or nullmailer.
Deliverability is hard no matter what software you use. You have to spend a while warming your IP addresses. This is one thing I’d call a hassle to self host. I’ve been using mxroute.com which is diy friendly and cheap.
I’m not trying to send mail directly from the host, only forward it to a host that’s prepared to send. I’m using Mailgun for that.
It has been a while since I touched ssmtp, so take what I’m saying with a grain of salt.
Problem with ssmtp and related when I was testing it was its behaviour in error conditions - due to a lack of any kind of spool it doesn’t fail very gracefully, and if the sending software doesn’t expect it and implement a spool itself (which it typically doesn’t have a reason to, as pretty much the only situation where something like sendmail would fail is a situation where it also wouldn’t be able to write a spool) this can very easily lead to loss of mails.
I already had a working SMTP client capable of fishing mails out of a Maildir at that point, so I ended up just doing a simple sendmail program throwing whatever it receives into a Maildir, and a cronjob to send this forward. This might be the most minimalistic setup for reliably sending out mail (and I’m using it an all my computers behind Emacs to do so) - but it is badly documented, so if you don’t care about reliability postfix might be a better choice, or if you don’t just go with ssmtp or similar. Or if you do want to dig into that message me, and I’ll help making things more user friendly.
Thanks. This is just for forwarding from mail and the like, so occasional loss of mail due to lack of spooling could be tolerated.
Acronyms, initialisms, abbreviations, contractions, and other phrases which expand to something larger, that I’ve seen in this thread:
Fewer Letters | More Letters |
---|---|
DNS | Domain Name Service/System |
IP | Internet Protocol |
SMTP | Simple Mail Transfer Protocol |
[Thread #679 for this sub, first seen 15th Apr 2024, 00:35] [FAQ] [Full list] [Contact] [Source code]
Postfix.
I use proxmox mail gateway (PMG) for my homelab, configured to relay through my Gmail domain using smtp auth.
I’ve also used PMG at the enterprise level. Never had an issue with it.
It’s postfix underneath.
I run Mailcow-dockerized for my mail server and internal relay, and it’s a postfix based system. Never have any issues with it.
lemmyreader@lemmy.ml 7 months ago
If your real SMTP server is doing fine, nullmailer is possibly the simplest of all smtp relay packages available.
markstos@lemmy.world 7 months ago
I found a nice Ansible role for nullmailer, but found that it is not packaged for Fedora, but msmtp and ssmtp are. I think I may try ssmtp next. Despite its unmaintained status, somewhow it’s packaged and nullmailer isn’t.