How to send email using another postfix server on the network

Let me start by saying I’m a complete noob with Unix/Linux email, so there are a lot of things I don’t know about this.

Here’s the scenario:

  • I have a couple of servers, including some VM’s, where I want to be able to send a “standard” email from cron, part of scripts, from command line etc.
  • On my main server, I want to install Postfix so emails can be sent from here to the internet.
  • I would like my other servers (including VM’s) to be able to use the main Postfix server on the network to send out emails.

I have found plenty of guides on installing a Postfix server - I’m pretty sure I got this covered.
So my question is, how do I set up the other servers to use a central Postfix server on the network? I want to do this in the most simple way possible, preferably if there is a “default” way to do this.

Also, I know nothing about the /etc/mail.rc and ~/.mailrc files, so any information about those would be appreciated as well.

Thanks in advance! :grinning: (PS: I’m using Ubuntu Server 20.04)

Ok I got this to work exactly as I wanted - here is what I did.

I installed postfix and opendkim on my main server, using the following guides:

Then I installed ssmtp on my “satellite” servers, with the following config file:

## Config file for sSMTP sendmail
mailhub=10.10.2.2:25 #IP of my server
UseTLS=YES
UseSTARTTLS=YES
hostname=mydomain.com

Now it works perfectly that all machines can send system email via the postfix server on 10.10.2.2. :+1: :grinning:

I should mention, that I installed ssmtp_2.64-9 from pkgs.org packaged for Ubuntu 20.10. This version has dependencies that are met by Ubuntu 20.04, and this works fine instead of ssmtp_2.64-8.1ubuntu1 included with 20.04.

2 Likes

Awesome, thanks for sharing. Hopefully this will help someone else.

1 Like