Postfix VM by Anarion Technologies
Postfix is an open-source mail transfer agent (MTA) designed to route and deliver email. It was developed by Wietse Venema at IBM’s T.J. Watson Research Center and released in 1998. Postfix is known for its robustness, security, and performance, making it a popular choice for both small and large-scale email systems.
The architecture of Postfix is modular, consisting of various independent components that handle different aspects of mail processing. This design allows for greater reliability and maintainability, as individual components can operate independently without affecting the overall system’s functionality. The primary components include the master process, SMTP server and client, queue manager, local delivery agent, and various filters and content inspection tools.
Security is a critical aspect of Postfix. It employs multiple layers of defense to protect against unauthorized access and abuse. Features like access control lists (ACLs), TLS encryption, and support for various authentication mechanisms ensure secure email communication. Performance is another key strength of Postfix. It is optimized to handle large volumes of email efficiently, making it suitable for use in environments ranging from personal servers to large enterprises and ISPs.Configuring Postfix is straightforward, thanks to its logical defaults and well-documented parameters. This ease of configuration, combined with its compatibility with Sendmail, facilitates smooth transitions from Sendmail to Postfix. The MTA’s reliability is further enhanced by its modular design, which isolates different functions into separate processes, preventing failures in one component from impacting the entire system.
Postfix’s extensibility allows for integration with third-party tools and services, such as spam filters and virus scanners, providing additional layers of email protection and management. Its vibrant community and extensive documentation offer robust support for users, ensuring that Postfix remains up-to-date with the latest security patches and features..
To subscribe to this product from Azure Marketplace and initiate an instance using the Azure compute service, follow these steps:
1. Navigate to Azure Marketplace and subscribe to the desired product.
2. Search for “virtual machines” and select “Virtual machines” under Services.
3. Click on “Add” in the Virtual machines page, which will lead you to the Create a virtual machine page.
4. In the Basics tab:
- Ensure the correct subscription is chosen under Project details.
- Opt for creating a new resource group by selecting “Create new resource group” and name it as “myResourceGroup.”
5. Under Instance details:
- Enter “myVM” as the Virtual machine name.
- Choose “East US” as the Region.
- Select “Ubuntu 18.04 LTS” as the Image.
- Leave other settings as default.
6. For Administrator account:
- Pick “SSH public key.”
- Provide your user name and paste your public key, ensuring no leading or trailing white spaces.
7. Under Inbound port rules > Public inbound ports:
- Choose “Allow selected ports.”
- Select “SSH (22)” and “HTTP (80)” from the drop-down.
8. Keep the remaining settings at their defaults and click on “Review + create” at the bottom of the page.
9. The “Create a virtual machine” page will display the details of the VM you’re about to create. Once ready, click on “Create.”
10. The deployment process will take a few minutes. Once it’s finished, proceed to the next section.
To connect to the virtual machine:
1. Access the overview page of your VM and click on “Connect.”
2. On the “Connect to virtual machine” page:
- Keep the default options for connecting via IP address over port 22.
- A connection command for logging in will be displayed. Click the button to copy the command. Here’s an example of what the SSH connection command looks like:
“`
ssh [email protected]
“`
3. Using the same bash shell that you used to generate your SSH key pair, you can either reopen the Cloud Shell by selecting >_ again
or going to https://shell.azure.com/bash.
4. Paste the SSH connection command into the shell to initiate an SSH session.
Usage/Deployment Instructions
Anarion Technologies – Postfix
Note: Search product on Azure marketplace and click on “Get it now”
Click on Continue
Click on Create
Creating a Virtual Machine, enter or select appropriate values for zone, machine type, resource group and so on as per your choice.
After Process of Create Virtual Machine. You have got an Option Go to Resource Group Click Go to Resource Group
Open Command Line if you are using windows or terminal if you using Linux And SSH into your Virtual Machine
To restart postfix run this command on your terminal:
$ sudo systemctl restart postfix
To show status of postfix run:
$ sudo systemctl status postfix
Note: If you need to ever return to change these settings, you can do so by typing:
$ sudo dpkg-reconfigure postfix
This installation
process will open a series of interactive prompts. For the purposes of this
tutorial, use the following information to fill in your prompts:
·
General type of mail configuration?: For
this, choose Internet Site since this matches our
infrastructure needs.
·
System mail name: This
is the base domain used to construct a valid email address when only the
account portion of the address is given. For instance, let’s say the hostname
of your server is mail.example.com. You
will likely want to set the system mail name to example.com so
that, given the username user1,
Postfix will use the address [email protected]
·
For example :
gmail.com (domain name)
·
Root and postmaster mail recipient: This
is the Linux account that will be forwarded mail addressed to root@ and postmaster@. Use
your primary account for this. In this example case, sammy.
·
Other destinations to accept mail for: This
defines the mail destinations that this Postfix instance will accept. If you
need to add any other domains that this server will be responsible for
receiving, add those here. Otherwise, the default will be sufficient.
·
Force synchronous updates on mail
queue?: Since you are likely using a journaled filesystem,
accept No here.
·
Local networks: This
is a list of the networks for which your mail server is configured to relay
messages. The default will work for most scenarios. If you choose to modify it,
though, make sure to be very restrictive in regards to the network range.
·
Mailbox size limit: This
can be used to limit the size of messages. Setting it to 0 disables
any size restriction.
·
Local address extension character: This
is the character that can be used to separate the regular portion of the
address from an extension (used to create dynamic aliases). The default, + will
work for this tutorial.
·
Internet protocols to use:
Choose whether to restrict the IP version that Postfix supports. For the
purposes of this tutorial, pick all.
To be explicit, these
are the settings used in this guide:
·
General type of mail configuration?: Internet
Site
·
System mail name: example.com (not mail.example.com)
·
Root and postmaster mail recipient: The
username of your primary Linux account (sammy in our examples)
·
Other destinations to accept mail for: $myhostname, example.com, mail.example.com, localhost.example.com,
localhost
·
Force synchronous updates on mail
queue?: No
·
Local networks: 127.0.0.0/8
[::ffff:127.0.0.0]/104 [::1]/128
·
Mailbox size limit: 0
·
Local address extension character: +
Internet protocols to
use: all
Configure Postfix
Once Postfix is installed, you need to configure it to use
Gmail as a relay for all emails. Open the main Postfix configuration file by
using the following command −
$ sudo nano /etc/postfix/main.cf
Add the following lines to the end of the file −
relayhost = [smtp.gmail.com]:587
smtp_use_tls = yes
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
Save and exit the file.
Create a Gmail App Password
To use Gmail as a relay server, you need to create an App
Password in Gmail configuration. This password is use to authenticate Gmail’s
servers for relaing emails. To create an App Password, you can follow these
steps −
- Log in to your Gmail account.
- Go to your Google Account settings page.
- Click on “Security”.
- Under “Signing in to Google”, click on “App Passwords”.
- Select “Mail” as the app and “Other (Custom Name)” as the device.
- Enter a name for the password and click on “Generate”.
- Make a note of the password that is generated.
Add Gmail Credentials in Postfix
Now that you have created an App Password, you need to add
it to Postfix. Create a new file called “sasl_passwd” in the
/etc/postfix directory by running the following command −
$ sudo nano /etc/postfix/sasl_passwd
Add the following line to the file, replacing “[email protected]” with your Gmail address and
“your-password” with the App Password that you generated
[smtp.gmail.com]:587 [email protected]:your-password
Save and exit the file.
Now, use following command to hash the sasl_passwd file −
$ sudo postmap /etc/postfix/sasl_passwd
RestartPostfix
Now restart Postfix service to apply the changes by using
following command −
$ sudo systemctl restart postfix
Fix Ownership and Permissions
$ sudo chown -R root:root /var/spool/postfix/lib
$ sudo chown -R root:root /var/spool/postfix/usr
Fix
Ownership of Subdirectories:
$ sudo chown -R root:root /var/spool/postfix/lib/x86_64-linux-gnu
$ sudo chown -R root:root /var/spool/postfix/usr/lib
$ sudo chown -R root:root /var/spool/postfix/usr/lib/zoneinfo
$ sudo chown -R root:root /var/spool/postfix/usr/lib/sasl2
Fix Permissions for Lock File:
$ sudo touch /var/lib/postfix/master.lock
$ sudo chown postfix:postfix /var/lib/postfix/master.lock
$ sudo chmod 644 /var/lib/postfix/master.lock
To send an email using the mail
command with the configuration you’ve set up, make sure that the mail
utility is installed on your system. If it is not installed, you can install it using the following command (for Debian-based systems):
$ sudo apt-get install mailutils
Test the Configuration
To test configuration, send an email using the “mail” commans, and replace “[email protected]” with the email address you want to send the email to −
echo “Test email” | mail -s “Test subject” [email protected]
The prompts will be pre-populated with your previous responses.
When the installation process finishes, you’re ready to make a few updates to your Postfix configuration.
Replace [email protected] with actual email address
ThankYou!!!!