Help with configuring OpenSMTPD as a SMTP relay

Use case: I want to get emails as notifications from local’s application.

As external MTU I chose service. But it doesn’t matter I can switch to any other if it matters
So I installed opensmtpd here is a config which I just a little tune:

Here is aliases file

To test email I do

+❯ echo "This is the body of the email" | mail -s "11111This is the subject line" root (also tried webcapcha and real email address)

Local emails I get which were put in ~/Maildir directory. But sendingblue doesn’t work.

In logs I see:
home-laptop smtpd[37451]: 3aff4f4b3b3d9d99 smtp envelope evpid=3b50d93165faebe4 from=<webcapcha@home-laptop> to=<mipa****>

There is not other topics regarding opensmtpd here on the forum. Really already spent few days trying to fix it up.

Hi @webcaptcha,


Hope it helps!

No it doesn’t help. Even that config is a bit outdated (check discussion page)

As I told I’ve spend already few days not only with archlinux wiki but with other guides over internet.

What do you mean by MTU in this context?

This is expected, so the local action for mails works.

This looks like a local mail that needs to be send to a non local mail. This will get over the relay. If this is the only log entry you can find, you might want to start smtpd with -v . Also you might want to check with a tool like Wireshark if a smtp connection is to your relay is created. It might be encrypted, but you should see the connection. If there is a connection, you need to get in touch with your “Marketing Partner” sendinblue.

Btw., why do you do it so complicated. Just relay over a normal mail account. Gmail is always a little problematic, since Google doesn’t like the old login methods. But there a lots of other mail provider that can be used to send mails to your Gmail account. Just use opensmtp or my favorite msmtp to send mail form your local system over a normal mail provider. (With msmtp you need extra software to save mail locally, it is just for sending it out. But with sendmail compatibility)

opensmtp is the MTU on my side and in my case sendinblue as MTU on other side which will relay it to the gmail. But I’m not insist that I’m correct I’m newbie about this.

yes local mails works good

you mean without needed outh2. And that providers will re-send mail to the gmail? Can you suggest a couple?

You don’t need in-between you and google as you can setup your google account.

Just remember - google may change such settings as they see fit but below page may be of help guidding you in setting up OpenSMTPD for your usecase

Less secure apps - * This setting is no longer available. Learn more

If you enable IMAP on your gmail - you should be able send mail using

$(username:passwd | base64)

But that may be disabled too - I know it has been possible

There is a third option for Google account

  • Enable two-factor authentication on your google account
  • Then you can add an app paasword which you can use to authenticate when sending email from your system.

Yet some another thoughts

  • Most ISP restrict/block outgoing SMTP traffic - due to spamming.
  • Because of this restriction ISP usually provide an outgoing email service which can be used as relay service for their customers…
  • If you own a domain name (and you are not hosting it on your own) the hosting provider often provides SMTP service as part of the hosting plan.

If OpenSMTPD is not a requirement it may be easier to setup msmtp

It is more a MTA as a MTU. But the lines between a MTA and a MSA are a little bit blury. And since opensmtp also stores mail locally, some might call it a MDA. So may acronyms. :man_shrugging:

This is how emails work. When you write an email form your gmail account with Thunderbird for example, Thunderbird transfer the email via SMTP to your mail provider and they transfer the mail to whatever server it needs to go.
And of course, if gmail would have a little better login options, you would simply send the mail to yourself. You can send emails form a account to the same account.

Since I’m form Germany only german free mailer come to mind. Another big player is . But I tested some, and a problem is that they will reject the mail, if the “body to” just contains root. Even if the “envelop to” is correctly set. I’m not sure about opensmtp, but msmtp can’t change the “body to”. Depending on the program that sends the mail, there might be options to change the recipient.

I also noticed that the error form the server is above this line in the journal.

And this line you posted is cut off. It also contains the error. systemctl and journalctl use by default a pager like less.
But you can use the --no-pager option with journalctl if you want. It works like

journalctl --no-pager -u smtpd.service

An email - in it’s most simple form - is a text file with a few specific properties

From: webserver <noreply@domain.tld>
To: Me <me@another-domain.tld>
Subject: Test of email service
MIME-Version: 1.0
Content-Type: text/plain
Congratulation - it works!