This article will try to summarize the installation and configuration of the POSTFIX mail server to be able to send using SMTP of your server.
Here we will know how to install and configure the Postfix daemon on Ubuntu 18.04 will be explained. First Connect to your server using SSH connection with your username/password. Note you may have permission file to connect also
Then do a apt-get update if you are on ubuntu then install postfix. make a sudo if rejected.
apt-get install postfix
You will see this screen. All Postfix configuration files are present in the / etc / postfix / folder. The two main files are main.cf and master.cf, although, for now, all you need to do is edit the main.cf file.
choose “Internet Site”.
- No configuration means the installation process will not configure any parameters.
- Internet Site means using Postfix for sending emails to other MTAs and receiving emails from other MTAs.
- Internet with smart host means using postfix to receive email from other MTAs, but using another smart host to relay emails to the recipient.
- Satellite system means using smart host for sending and receiving emails.
- Local only means emails are transmitted only between local user accounts.
The System mail name should be the same as the name you assigned to the server when you were creating it. just change it to your server name like yourdomain.com When you’ve finished, press
Now POSTFIX is installed, the next step is to configure it. Run the following to know the status
service postfix status
Now the Domain Works
We have to register a mail server on our DNS setting. Add a A Record in DNS settings. Just add a name and IP of your server
A Record mailer XX.XXX.XX.XX
mailer can be anything like
mailme …. A mail server can be mailer.domain.anme will point to our postfix mail server
Also add a mx record for linking our mails to redirect to our mail server. Mails works in a different setting so we have to point to via MX DNS.
MX Record domain.name mailer.domain.name
This tells that mails for our domain will be handled by mailer.domain.name. We could have just pointed to domain.name with the A Record but separation keeps the system more modular and easy to handle.
The DNS setting will take some time to reflect changes. Until that. just set our hostname to the FQDN like this
sudo hostnamectl set-hostname mailer.domain.name
Let try to send mail . Install mailutils to test email using our console
apt-get install mailutils
and send to someone email address
echo "Sent By This Server to Test POSTFIX" | mail -s "This is subject line Server Send Mail " email@example.com
And check your email id . In a few seconds you will get a mail
Now we have a mail but on SPAM. Since we have not verified our domain and other SPF stuff. That would be later. But we have a mail from our own server without 3rd party service. Sending mail is not limited to console, but you can use mail function via your PHP mail function to send also.