Mail Servers – TecAdmin https://tecadmin.net How to guide for System Administrator's and Developers Mon, 12 Dec 2022 05:53:16 +0000 en-US hourly 1 https://wordpress.org/?v=6.1.1 Postfix: Configure SASL Authentication for Remote SMTP https://tecadmin.net/postfix-configure-sasl-authentication-for-remote-smtp/ https://tecadmin.net/postfix-configure-sasl-authentication-for-remote-smtp/#respond Sun, 11 Dec 2022 05:32:22 +0000 https://tecadmin.net/?p=32540 Postfix SASL Authentication is one of the most popular methods for remote SMTP authentication. It’s a secure, reliable, and highly configurable way of sending and receiving emails. Essentially, the Postfix SASL Authentication consists of an authentication server and a client. The client is a mail program that sends the message, and the authentication server validates [...]

The post Postfix: Configure SASL Authentication for Remote SMTP appeared first on TecAdmin.

]]>
Postfix SASL Authentication is one of the most popular methods for remote SMTP authentication. It’s a secure, reliable, and highly configurable way of sending and receiving emails. Essentially, the Postfix SASL Authentication consists of an authentication server and a client. The client is a mail program that sends the message, and the authentication server validates the credentials of the user. Once authentication is successful, the message is sent and authenticated at the receiving server.

The following step will configure the Postfix server to relay emails from a remote SMTP server with authentication.

  1. First of all, configure the custom relayhost parameter. This will configure postfix to relay emails via the remote SMTP servers.
    sudo postconf -e "relayhost = smtp.gmail.com:587" 
    

    You can also configure the Postfix server for d relaying emails based on the sender address.

  2. create an SMTP host and authentication mapping file:
    sudo nano /etc/postfix/smtp_sasl_password 
    

    Add your remote SMTP host and credentials one per line. See the below example:

    smtp.gmail.com           your_email@gmail.com:your_email_password
    

    Save the file and close it.

  3. Next use the postmap command to update the Postfix lookup table for the above-created configuration file.
    sudo postmap /etc/postfix/smtp_sasl_password  
    
  4. Update the Postfix main configuration file with the following commands:
    sudo postconf -e "smtp_sasl_auth_enable = yes"
    sudo postconf -e "smtp_sasl_password_maps = hash:/etc/postfix/smtp_sasl_password"
    sudo postconf -e "smtp_sasl_security_options ="
    
  5. Finally, restart the Postfix service
    sudo systemctl restart postfix
    
  6. All done. You can verify the changes by sending an email via the configured remote SMTP servers.

Postfix SASL Authentication provides a secure way to transfer emails, and it’s easy to set up. It also allows you to customize the authentication process, so if you want to use things like two-factor authentication or IP whitelisting, you can. Overall, Postfix SASL Authentication is a great option for anyone who needs a secure and reliable way to transfer emails. It’s a must-have for anyone who takes security seriously!

The post Postfix: Configure SASL Authentication for Remote SMTP appeared first on TecAdmin.

]]>
https://tecadmin.net/postfix-configure-sasl-authentication-for-remote-smtp/feed/ 0
How to Install and Configure Postfix on Ubuntu 20.04 https://tecadmin.net/how-to-install-and-configure-postfix-on-ubuntu-20-04/ https://tecadmin.net/how-to-install-and-configure-postfix-on-ubuntu-20-04/#comments Sun, 10 Oct 2021 17:11:57 +0000 https://tecadmin.net/?p=23605 Postfix is a popular Mail transfer agent(MTA) which is a part of SMTP whose full form is Simple Mail transfer protocol and Postfix’s function is to transfer/send mails from one server to another. Postfix is known because of its determination of routes and sending emails; it is completely free and installable on all major Unix [...]

The post How to Install and Configure Postfix on Ubuntu 20.04 appeared first on TecAdmin.

]]>
Postfix is a popular Mail transfer agent(MTA) which is a part of SMTP whose full form is Simple Mail transfer protocol and Postfix’s function is to transfer/send mails from one server to another. Postfix is known because of its determination of routes and sending emails; it is completely free and installable on all major Unix operating systems. Around 25% of all public servers use or run postfix on the internet.

As it is installable on all major Unix operating systems, in this article we will provide a step-by-step guide about how to install and configure Postfix on Ubuntu 20.04.

How to Install Postfix on Ubuntu

Step 1. The first step in installing Postfix is to update our system packages by typing or copying the following command in Debian 11 terminal and then pressing enter:

sudo apt update 

Step 2. Now that we have successfully updated our package index, let us continue by typing the following command in our Ubuntu Terminal which will install Postfix on Ubuntu 20.04:

sudo DEBIAN_PRIORITY=low apt install postfix 

Before going further let me explain that Debian_Priority is an environmental variable whose function is to let us configure some additional options as well with the installation of Postfix.

Step 3. When you execute the step2 command, you will be redirected to the Mail Server configurations. Read all of the configurations and navigate to the ok button using the keyboard’s left or right button.

Step 3 - Installing Postfix on Ubuntu 20.04

Step 4. After pressing ok you will be directed to the following page where you have to select the Internet Site option from the given options. By choosing the Internet Site you are configuring your Mail server. After selecting Internet Site press Enter.

Step 4 - Installing Postfix on Ubuntu 20.04

Step 5. Now you will be asked to choose System Mail Name or FQDN which stands for Fully Qualified Domain Name. I would name it tecadmin.com but you can choose whatever is suitable for you or your registered domain name. After typing your domain name, press ok.

Step 5 - Installing Postfix on Ubuntu 20.04

Step 6. After setting your mail name, you will be redirected to the Root and Postmaster Mail recipient page where you have to set your root and postmaster Mail, Recipient. You can keep the root and postmaster the same as your username. I have set mine to be tecadmin@. Navigate to ok and press enter.

Step 6 - Installing Postfix on Ubuntu 20.04

Step 7. After root and postmaster configuration, you will be redirected to the page where you have to set all the possible domains for which your mail server will be capable of accepting emails. They provide you with default values, however, you can add other domains as well. When you are done, navigate to ok and press Enter.

Step 7 - Installing Postfix on Ubuntu 20.04

Step 8. After adding the possible domains, the next step is whether you want to force synchronous updates of the mail queue or not for which the default option is no and we will also go with no by pressing enter.

Step 8 - Installing Postfix on Ubuntu 20.04

Step 9. When you press Enter, you will be directed towards the setting of the local networks which we can modify according to our needs, or go with the default one’s provided already in the input box by navigating to ok and pressing enter.

Step 9 - Installing Postfix on Ubuntu 20.04

Step 10. The next step is to limit our Mailbox size to bytes. It means to specify the size of our mailbox accepting messages and the default value is zero hence no restriction on the size of the messages. We will navigate to ok and press enter with the default value.

Step 10 - Installing Postfix on Ubuntu 20.04

Step 11. In this step, we have to select a Local Address Extension Character that has a default value with + and we will go with the default value by navigating to ok and pressing enter.

Step 9 - Installing Postfix on Ubuntu 20.04

Step 12. This is the last step in configuring postfix in which we will choose the Internet protocol that we want to or we will use. I will select all options by pressing enter.

Step 12 - Installing Postfix on Ubuntu 20.04

Step 13. After pressing Enter in the previous step, the installation of postfix will continue to completion and when the installation will be complete the following output will be seen:

Congratulations! We have successfully installed and configured Postfix on Ubuntu 20.04. We can check the status of Postfix installed with:

sudo systemctl status postfix 
Output
● postfix.service - Postfix Mail Transport Agent Loaded: loaded (/lib/systemd/system/postfix.service; enabled; vendor preset: enabled) Active: active (exited) since Sun 2021-10-10 08:59:06 UTC; 22s ago Main PID: 3438 (code=exited, status=0/SUCCESS) Tasks: 0 (limit: 1071) Memory: 0B CGroup: /system.slice/postfix.service

Conclusion

Postfix is a popular, common mail server that has an easy process of installing and configuring and is used to route and deliver email on UNIX operating systems.

In this article, we installed and configured Postfix on Ubuntu 20.04 by simplifying it as much as possible by using a stepwise sequence. If you followed this article, we are sure you must have installed and configured postfix on Ubuntu 20.04 without any errors.

The post How to Install and Configure Postfix on Ubuntu 20.04 appeared first on TecAdmin.

]]>
https://tecadmin.net/how-to-install-and-configure-postfix-on-ubuntu-20-04/feed/ 1
How to Install Sendmail on Ubuntu 18.04 & 16.04 LTS https://tecadmin.net/install-sendmail-on-ubuntu/ https://tecadmin.net/install-sendmail-on-ubuntu/#comments Sun, 17 Feb 2019 14:56:15 +0000 https://tecadmin.net/?p=18005 Sendmail is a general purpose email routing facility used for email transport over the Internet. It includes SMTP (Simple Mail Transfer Protocol) for the mail-transfer and email delivery. Most of the system administrators preferred to use Sendmail server as MTA than other MTAs. You can also use Sendmail server to send the email via external [...]

The post How to Install Sendmail on Ubuntu 18.04 & 16.04 LTS appeared first on TecAdmin.

]]>
Sendmail is a general purpose email routing facility used for email transport over the Internet. It includes SMTP (Simple Mail Transfer Protocol) for the mail-transfer and email delivery. Most of the system administrators preferred to use Sendmail server as MTA than other MTAs. You can also use Sendmail server to send the email via external SMTP servers like Gmail, Amazon SES, MailChimp etc.

1. Remove Postfix

Postfix is the default SMTP service pre-installed on Ubuntu operating systems. And you are willing to use Sendmail server on your system.

First of all, remove the existing postfix installation on Ubuntu.

sudo systemctl stop postfix
sudo apt remove postfix && apt purge postfix

2. Install Sendmail

If you don’t have installed Sendmail using the following command to install Sendmail with other required packages using yum package manager.

sudo apt install sendmail

3. Configure Sendmail Server

The execute the sendmailconfig command to complete the basic configuration.

sudo sendmailconfig

Select all options to ‘Y’ and press enter. Wait for the command finish.

Your server is ready for sending emails. You can use the Linux command line or PHP script to send emails.

4. Receive Incomming Emails

Edit /etc/mail/sendmail.mc file and comment below line to allow receiving an email from anywhere. To comment a line in sendmail.mc, just put dnl keyword at the start of the line.

dnl DAEMON_OPTIONS(`Family=inet,  Name=MTA-v4, Port=smtp, Addr=127.0.0.1')dnl
dnl DAEMON_OPTIONS(`Family=inet,  Name=MSP-v4, Port=submission, M=Ea, Addr=127.0.0.1')dnl

Then add your domain names to /etc/mail/local-host-names file.

cat /etc/mail/local-host-names

tecadmin.net
mail.tecadmin.net
localhost
localhost.localdomain

Now use m4 is a macro processor to compile the Sendmail configuration files. m4 is stream-based, that is, it doesn’t understand about lines.

sudo m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf

Restart Sendmail service

sudo systemctl restart sendmail

Your system is ready for incoming emails.

5. Configure Domain-based E-mail Routing

As we read above that virtusertable file used for aliasing, allowing multiple virtual domains to be hosted on one machine.

  • 1. All emails addressed to @example.com domain delivered to support@mydomain.com
    @example.com support@mydomain.com
    
  • 2. All emails addressed to support@mydomain.com will forward to local user jack.
    support@mydomain.com  jack
    
  • 3. All emails addressed to @mydomain.com will forward to domain @otherdomain.com with corresponding usernames.
    @mydomain.com    %1@otherdomain.com
    
  • 4. All emails addressed to @otherdomain.com will be rejected my mail server with acknowledging sender with the message
    @otherdomain.com 	 error:nouser User unknown
    

After making all changes in virtusertable execute following command to create updated virtusertable.db file containing the new configuration.

sudo makemap hash /etc/mail/virtusertable < /etc/mail/virtusertable

Now restart Sendmail service

sudo /etc/init.d/sendmail restart

Thanks for reading this article. I hope this article will help you to configure Sendmail on Ubuntu Linux systems.

References:
http://www.sendmail.com/
http://www.sendmail.com/sm/open_source/docs/m4/intro_m4.html

The post How to Install Sendmail on Ubuntu 18.04 & 16.04 LTS appeared first on TecAdmin.

]]>
https://tecadmin.net/install-sendmail-on-ubuntu/feed/ 8
How to Install Sendmail on Debian 9 (Stretch) https://tecadmin.net/install-sendmail-on-debian-9-stretch/ https://tecadmin.net/install-sendmail-on-debian-9-stretch/#comments Thu, 14 Feb 2019 16:00:42 +0000 https://tecadmin.net/?p=18007 Sendmail is a MTA (Mail Transfer Agent) server used for transferring email from between different hosts. Sendmail uses SMTP (Simple Mail Transfer Protocol) protocol. Most of the system administrators preferred to use Sendmail server as MTA than other MTAs. This tutorial helps you to Install Sendmail on Debian 9 (Stretch) Linux system. 1. Install Sendmail [...]

The post How to Install Sendmail on Debian 9 (Stretch) appeared first on TecAdmin.

]]>
Sendmail is a MTA (Mail Transfer Agent) server used for transferring email from between different hosts. Sendmail uses SMTP (Simple Mail Transfer Protocol) protocol. Most of the system administrators preferred to use Sendmail server as MTA than other MTAs. This tutorial helps you to Install Sendmail on Debian 9 (Stretch) Linux system.

1. Install Sendmail

If you don’t have installed Sendmail using the following command to install Sendmail with other required packages using the apt package manager.

sudo apt update
sudo apt install sendmail sendmail-cf m4

2. Configure Sendmail Server

Now, execute the sendmailconfig command to complete the basic configuration.

sudo sendmailconfig

Select all options to ‘Y’ and press enter. Wait for the command finish.

Your server is ready for sending emails. You can use the Linux command line or PHP script to send emails.

3. Receive Incomming Emails

Edit /etc/mail/sendmail.mc file and comment below line to allow receiving an email from anywhere. To comment a line in sendmail.mc, just put dnl keyword at the start of the line.

dnl DAEMON_OPTIONS(`Family=inet,  Name=MTA-v4, Port=smtp, Addr=127.0.0.1')dnl
dnl DAEMON_OPTIONS(`Family=inet,  Name=MSP-v4, Port=submission, M=Ea, Addr=127.0.0.1')dnl

Then add your domain names to /etc/mail/local-host-names file.

cat /etc/mail/local-host-names

tecadmin.net
mail.tecadmin.net
localhost
localhost.localdomain

Now use m4 is a macro processor to compile the Sendmail configuration files. m4 is stream-based, that is, it doesn’t understand about lines.

sudo m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf

Restart Sendmail service

sudo systemctl restart sendmail

Your system is ready for incoming emails.

4. Configure Domain-based E-mail Routing

As we read above that virtusertable file used for aliasing, allowing multiple virtual domains to be hosted on one machine.

  • 1. All emails addressed to @example.com domain delivered to support@mydomain.com
    @example.com support@mydomain.com
    
  • 2. All emails addressed to support@mydomain.com will forward to local user jack.
    support@mydomain.com  jack
    
  • 3. All emails addressed to @mydomain.com will forward to domain @otherdomain.com with corresponding usernames.
    @mydomain.com    %1@otherdomain.com
    
  • 4. All emails addressed to @otherdomain.com will be rejected my mail server with acknowledging sender with the message
    @otherdomain.com 	 error:nouser User unknown
    

After making all changes in virtusertable execute the following command to create an updated virtusertable.db file containing the new configuration.

sudo makemap hash /etc/mail/virtusertable < /etc/mail/virtusertable

Also make sure the following entry is added in sendmail.mc file.

FEATURE(`virtusertable')

Add entry if not available and compile configuration file

sudo m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf

Now restart Sendmail service

sudo systemctl restart sendmail

Thanks for reading this article. I hope this article will help you to configure Sendmail on Debian 9 (Stretch) system.

References:
http://www.sendmail.com/
http://www.sendmail.com/sm/open_source/docs/m4/intro_m4.html

The post How to Install Sendmail on Debian 9 (Stretch) appeared first on TecAdmin.

]]>
https://tecadmin.net/install-sendmail-on-debian-9-stretch/feed/ 1
How to Install Sendmail on Fedora 32/31/30 https://tecadmin.net/install-sendmail-on-fedora/ https://tecadmin.net/install-sendmail-on-fedora/#comments Mon, 11 Feb 2019 14:36:05 +0000 https://tecadmin.net/?p=18006 Sendmail is a general purpose email routing facility used for email transport over the Internet. It includes SMTP (Simple Mail Transfer Protocol) for the mail-transfer and email delivery. Most of the system administrators preferred to use Sendmail server as MTA than other MTAs. You can also use Sendmail server to send the email via external [...]

The post How to Install Sendmail on Fedora 32/31/30 appeared first on TecAdmin.

]]>
Sendmail is a general purpose email routing facility used for email transport over the Internet. It includes SMTP (Simple Mail Transfer Protocol) for the mail-transfer and email delivery. Most of the system administrators preferred to use Sendmail server as MTA than other MTAs. You can also use Sendmail server to send the email via external SMTP servers like Gmail, Amazon SES, MailChimp etc.

1. Install Sendmail

If you don’t have installed Sendmail using the following command to install Sendmail with other required packages using yum package manager.

sudo dnf install sendmail sendmail-cf

2. Configure Sendmail on Fedora

Before starting configuration we must know about various Sendmail configuration files exists in /etc/mail directory.

  • access — Allow/Deny other systems to use Sendmail for outbound emails.
  • domaintable — Used for domain name mapping for Sendmail.
  • local-host-names — Used to define aliases for the host.
  • mailertable — Defined the instructions that override routing for particular domains.
  • virtusertable — Specifies a domain-specific form of aliasing, allowing multiple virtual domains to be hosted on one machine.

2.1 Comment out below line in /etc/mail/sendmail.mc to allow receiving email from anywhere. To comment a line in sendmail.mc, just put dnl at start of line.

dnl DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA')dnl

2.2 Add this line also in sendmail.mc above ‘MAILER’ option

FEATURE(`relay_hosts_only')dnl

2.3 Add your PC’s full hostname in this file.

hostname >> /etc/mail/relay-domains

3. Recompile Configuration File

m4 ia a macro processor to compile the Sendmail configuration files. m4 is stream-based, that is, it doesn’t understand about lines.

sudo m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf

Restart Sendmail service

sudo systemctl restart sendmail

4. Configure Domain-based E-mail Routing

As we read above that virtusertable file used for aliasing, allowing multiple virtual domains to be hosted on one machine.

  • 1. All emails addressed to @example.com domain delivered to support@mydomain.com
    @example.com support@mydomain.com
    
  • 2. All emails addressed to support@mydomain.com will forward to local user jack.
    support@mydomain.com  jack
    
  • 3. All emails addressed to @mydomain.com will forward to domain @otherdomain.com with corresponding usernames.
    @mydomain.com    %1@otherdomain.com
    
  • 4. All emails addressed to @otherdomain.com will be rejected my mail server with acknowledging sender with the message
    @otherdomain.com 	 error:nouser User unknown
    

After making all changes in virtusertable execute following command to create updated virtusertable.db file containing the new configuration.

makemap hash /etc/mail/virtusertable < /etc/mail/virtusertable

Finally, restart the Sendmail service to apply changes

sudo systemctl restart sendmail

Thanks for reading this article. I hope this article will help you to configure Sendmail on Fedora systems.

References:
http://www.sendmail.com/
http://www.sendmail.com/sm/open_source/docs/m4/intro_m4.html

The post How to Install Sendmail on Fedora 32/31/30 appeared first on TecAdmin.

]]>
https://tecadmin.net/install-sendmail-on-fedora/feed/ 1
How to Install and Use Imapsync on Ubuntu & Debian https://tecadmin.net/use-imapsync-on-ubuntu/ https://tecadmin.net/use-imapsync-on-ubuntu/#comments Fri, 12 May 2017 17:28:53 +0000 https://tecadmin.net/?p=12600 Imapsync is an IMAP transfer tool used for copying emails from one IMAP server to another IMAP server. This article will help you to install imapsync on Ubuntu, Debian, and Linuxmint systems and transfer all your Mailboxes and emails between two IMAP servers. Read this => How To Install Postfix Mail Server on Ubuntu Step [...]

The post How to Install and Use Imapsync on Ubuntu & Debian appeared first on TecAdmin.

]]>
Imapsync is an IMAP transfer tool used for copying emails from one IMAP server to another IMAP server. This article will help you to install imapsync on Ubuntu, Debian, and Linuxmint systems and transfer all your Mailboxes and emails between two IMAP servers.

Step 1 – Prerequisites

Let’s start with the installation of the required packages for imapsync. Here is a long list of Perl libraries and other packages to install on your system.

sudo apt-get install git rcs make makepasswd cpanminus

sudo apt-get install gcc libssl-dev libauthen-ntlm-perl \ 
     libclass-load-perl libcrypt-ssleay-perl liburi-perl \
     libdata-uniqid-perl libdigest-hmac-perl libdist-checkconflicts-perl \
     libfile-copy-recursive-perl libio-compress-perl libio-socket-inet6-perl \
     libio-socket-ssl-perl libio-tee-perl libmail-imapclient-perl \
     libmodule-scandeps-perl libnet-ssleay-perl libpar-packer-perl \
     libreadonly-perl libsys-meminfo-perl libterm-readkey-perl \
     libtest-fatal-perl libtest-mock-guard-perl libtest-pod-perl \
     libtest-requires-perl libtest-simple-perl libunicode-string-perl  

Also, install required Python modules using CPAN on your system.

sudo cpanm Crypt::OpenSSL::RSA Crypt::OpenSSL::Random --force
sudo cpanm Mail::IMAPClient JSON::WebToken Test::MockObject 
sudo cpanm Unicode::String Data::Uniqid

Step 2 – Install Imapsync

After completing the installation of required packages. Download latest imapsync code from its official Github repository on your local system.

git clone https://github.com/imapsync/imapsync.git

Navigate to newly cloned repository and install it with the following commands on your system.

cd imapsync
mkdir -p dist
sudo make install

At this stage, your system is ready to migrate all data from one email account to another email accounts using IMAP.

Step 3 – Transfer Emails with IMAP

So you are ready for migration. Before migration make sure both accounts have IMAP running and accessible from your system. After that use following command syntax.

imapsync --host1 imap.source.example.com  \
	   --user1 user@example.com 	    \
	   --password1 S0urcePassw0rd  	    \
	   --ssl1			    \
	   --host2 imap.dest.example.com    \
	   --user2 user@example.com 	    \
	   --password2 Dest1nat10NPassw0rd  \
	   --ssl2

The command will take a long time as per the size of your source Mailbox. After completing all process, you will see a long list of output. Check the output to find if any error occurred during transfer. Below is the small part of the result.

Transfer started at Thu May 11 11:45:37 2017
PID is 4969
...
...
...
Total bytes transferred           : 78373 (76.536 KiB)
Total bytes duplicate host1       : 0 (0.000 KiB)
Total bytes duplicate host2       : 0 (0.000 KiB)
Total bytes skipped               : 0 (0.000 KiB)
Total bytes error                 : 0 (0.000 KiB)
Message rate                      : 0.1 messages/s
Average bandwidth rate            : 3.0 KiB/s
Memory consumption                : 217.0 MiB
Biggest message                   : 57947 bytes (56.589 KiB)
Memory/biggest message ratio      : 3927.0
Start difference host2 - host1    : -2 messages, -78373 bytes (-76.536 KiB)
Final difference host2 - host1    : 0 messages, 0 bytes (0.000 KiB)
Detected 0 errors

Reference:

The post How to Install and Use Imapsync on Ubuntu & Debian appeared first on TecAdmin.

]]>
https://tecadmin.net/use-imapsync-on-ubuntu/feed/ 14
Configure Sendmail to Relay Emails through Gmail SMTP https://tecadmin.net/sendmail-to-relay-emails-through-gmail-stmp/ https://tecadmin.net/sendmail-to-relay-emails-through-gmail-stmp/#comments Mon, 12 Sep 2016 14:54:49 +0000 https://tecadmin.net/?p=10761 Sendmail provides the option to send emails via the external SMTP servers. This tutorial will help you to configure Sendmail to relay email through external SMTP servers like Gmail, Amazon SES, Mailchimp, Mandrill etc. In this tutorial, we are using the Gmail SMTP server to relay emails from Sendmail server. 1. Create Auth File First [...]

The post Configure Sendmail to Relay Emails through Gmail SMTP appeared first on TecAdmin.

]]>
Sendmail provides the option to send emails via the external SMTP servers. This tutorial will help you to configure Sendmail to relay email through external SMTP servers like Gmail, Amazon SES, Mailchimp, Mandrill etc. In this tutorial, we are using the Gmail SMTP server to relay emails from Sendmail server.

1. Create Auth File

First create directory for storing authentication files.

sudo mkdir /etc/mail/authinfo
sudo chmod 700 /etc/mail/authinfo

Now, create an auth file with any name like smtp-auth and add the following content. Replace the above email with your gmail or google apps email.

sudo vi /etc/mail/authinfo/smtp-auth
AuthInfo: "U:root" "I:user@gmail.com" "P:PASSWORD"

Now create a hash map file of above created auth file.

makemap hash /etc/mail/authinfo/smtp-auth < /etc/mail/authinfo/smtp-auth

2. Configure Sendmail with SMART_HOST

Now add following configuration lines into your sendmail.mc configuration file below "MAILER" definition.

 define(`SMART_HOST',`[smtp.gmail.com]')dnl
 define(`RELAY_MAILER_ARGS', `TCP $h 587')dnl
 define(`ESMTP_MAILER_ARGS', `TCP $h 587')dnl
 define(`confAUTH_OPTIONS', `A p')dnl
 TRUST_AUTH_MECH(`EXTERNAL DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl
 define(`confAUTH_MECHANISMS', `EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl
 FEATURE(`authinfo',`hash -o /etc/mail/authinfo/smtp-auth.db')dnl

In the next step we will need to re-build sendmail's configuration. To do that execute:

make -C /etc/mail

3. Verify Setup

After completing all the above configuration's, reload the sendmail service to apply changes.

sudo service sendmail reload

Now send a test email to verify everything is working fine.

echo "Test Email" | mail -s "Subject Here" recipient@example.com 

The post Configure Sendmail to Relay Emails through Gmail SMTP appeared first on TecAdmin.

]]>
https://tecadmin.net/sendmail-to-relay-emails-through-gmail-stmp/feed/ 10
How To Install Postfix on Ubuntu 18.04 & 16.04 LTS https://tecadmin.net/install-postfix-on-ubuntu/ https://tecadmin.net/install-postfix-on-ubuntu/#comments Thu, 23 Apr 2015 16:26:57 +0000 https://tecadmin.net/?p=6086 Postfix is fast and popular SMTP server widely used. The main job of Postfix is to relay mail locally or to an intended destination outside the network. Some of the most popular SMTP servers are Sendmail, Postfix, and Qmail. This article will help you to install Postfix on Ubuntu 18.10, 18.04 LTS, 16.04 LTS, and [...]

The post How To Install Postfix on Ubuntu 18.04 & 16.04 LTS appeared first on TecAdmin.

]]>
Postfix is fast and popular SMTP server widely used. The main job of Postfix is to relay mail locally or to an intended destination outside the network. Some of the most popular SMTP servers are Sendmail, Postfix, and Qmail. This article will help you to install Postfix on Ubuntu 18.10, 18.04 LTS, 16.04 LTS, and 14.04 LTS systems.

For this tutorial, we are using the FQDN as mail.tecadmin.net for configuring this host.

Step 1 – Install Postfix

Postfix packages are available under default repositories of Ubuntu operating systems. Simply use the following command to install Postfix SMTP server on your Ubuntu system.

sudo apt-get install postfix

The installation process will ask you for some inputs like below. Just

Install Postfix on Ubuntu

Install Postfix on Ubuntu

Step 2 – Configure Postfix

Let’s start Postfix configuration. Edit Postfix configuration file /etc/postfix/main.cf in your favourite editor and make following changes. Change myhostname, mydomain as per your requirements.

  myhostname = host.tecadmin.net
  mydomain = tecadmin.net
  myorigin = $mydomain
  mydestination = $myhostname, localhost, $mydomain, localhost.localdomain
  mynetworks = 127.0.0.0/8, /32
  relay_domains = $mydestination
  inet_interfaces = all
  inet_protocols = all
  home_mailbox = Maildir/

Step 3 – Restart Postfix Service

As we have done basic Postfix configuration, So restart Postfix service to read changes of configuration. Also, configure to autostart on system boot.

sudo service postfix restart

The post How To Install Postfix on Ubuntu 18.04 & 16.04 LTS appeared first on TecAdmin.

]]>
https://tecadmin.net/install-postfix-on-ubuntu/feed/ 3
How to flush Postfix Mail Queue https://tecadmin.net/flush-postfix-mail-queue/ https://tecadmin.net/flush-postfix-mail-queue/#comments Fri, 27 Feb 2015 07:19:05 +0000 https://tecadmin.net/?p=6356 Questions:- How do I flush Postfix mail queue? How to remove emails from mail queue in Postfix? Postfix flush mail queue? Postfix remove differed emails from the queue? Postfix empty the mail queue command line? This article will help you for flush or clear or delete emails from Postfix mail queue. This will also help [...]

The post How to flush Postfix Mail Queue appeared first on TecAdmin.

]]>
Questions:- How do I flush Postfix mail queue? How to remove emails from mail queue in Postfix? Postfix flush mail queue? Postfix remove differed emails from the queue? Postfix empty the mail queue command line?

This article will help you for flush or clear or delete emails from Postfix mail queue. This will also help you to delete emails from single mail queue or any specific email.

List All Emails

To list all mail of queue, use one of the following commands.

postqueue -p

Flush All Emails

To delete or flush all emails from Postfix mail queue using the following command.

postsuper -d ALL

Flush Deferred Mails Only

You can only delete all deferred emails only from the mail queue. Use the following command to delete deferred emails from the queue.

postsuper -d ALL deferred

Remove Specific Email

If you want to remove any specific email. Use the following command to remove specific emails only. First search the ID of that email like below command

postqueue -p | grep "email@example.com"

056CB129FF0*    5513 Sun Feb 26 02:26:27  email@example.com

Now delete the mail from mail queue with id 056CB129FF0.

postsuper -d 056CB129FF0

The post How to flush Postfix Mail Queue appeared first on TecAdmin.

]]>
https://tecadmin.net/flush-postfix-mail-queue/feed/ 7
How to Install Sendmail Server on CentOS/RHEL 7/6 https://tecadmin.net/install-sendmail-server-on-centos-rhel-server/ https://tecadmin.net/install-sendmail-server-on-centos-rhel-server/#comments Mon, 19 Jan 2015 07:06:00 +0000 https://tecadmin.net/?p=164 Sendmail is a MTA (Mail Transfer Agent) server used for transferring email from between different hosts. Sendmail uses SMTP (Simple Mail Transfer Protocol) protocol. Most of the system administrators preferred to use Sendmail server as MTA than other MTAs. RHEL 5 or its earlier versions were using Sendmail as a default mail server, But newer [...]

The post How to Install Sendmail Server on CentOS/RHEL 7/6 appeared first on TecAdmin.

]]>
Sendmail is a MTA (Mail Transfer Agent) server used for transferring email from between different hosts. Sendmail uses SMTP (Simple Mail Transfer Protocol) protocol. Most of the system administrators preferred to use Sendmail server as MTA than other MTAs.

RHEL 5 or its earlier versions were using Sendmail as a default mail server, But newer version’s of RHEL based systems adapted postfix as a default mail server. Most of the users are familiar with Sendmail and want to use it with version 6 also. This article will help users for installing Sendmail server on RHEL 7/6/5 or with minimal configuration.

1. Install Sendmail

If you don’t have installed Sendmail using the following command to install Sendmail with other required packages using yum package manager.

yum install sendmail sendmail-cf m4

2. Configure Sendmail Server

Before starting configuration we must know about various Sendmail configuration files exists in /etc/mail directory.

  • access — Allow/Deny other systems to use Sendmail for outbound emails.
  • domaintable — Used for domain name mapping for Sendmail.
  • local-host-names — Used to define aliases for the host.
  • mailertable — Defined the instructions that override routing for particular domains.
  • virtusertable — Specifies a domain-specific form of aliasing, allowing multiple virtual domains to be hosted on one machine.
  • 2.1 Comment out below line in /etc/mail/sendmail.mc to allow receiving email from anywhere. To comment a line in sendmail.mc, just put dnl at start of line.

    dnl DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA')dnl
    

    2.2 Add this line also in sendmail.mc above ‘MAILER’ option

    FEATURE(`relay_hosts_only')dnl
    

    2.3 Add your PC’s full hostname in this file.

    hostname >> /etc/mail/relay-domains
    

    3. Recompile Sendmail Configuration

    m4 ia a macro processor to compile the Sendmail configuration files. m4 is stream-based, that is, it doesn’t understand about lines.

    m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf
    

    Restart Sendmail service

    /etc/init.d/sendmail restart
    

    4. Configure Domain-based E-mail Routing

    As we read above that virtusertable file used for aliasing, allowing multiple virtual domains to be hosted on one machine.

    1. All emails addressed to @example.com domain delivered to support@mydomain.com

    @example.com support@mydomain.com
    

    2. All emails addressed to support@mydomain.com will forward to local user jack.

    support@mydomain.com  jack
    

    3. All emails addressed to @mydomain.com will forward to domain @otherdomain.com with corresponding usernames.

    @mydomain.com    %1@otherdomain.com
    

    4. All emails addressed to @otherdomain.com will be rejected my mail server with acknowledging sender with the message

    @otherdomain.com 	 error:nouser User unknown
    

    After making all changes in virtusertable execute following command to create updated virtusertable.db file containing the new configuration.

    makemap hash /etc/mail/virtusertable < /etc/mail/virtusertable
    

    Now restart Sendmail service

    /etc/init.d/sendmail restart
    

    Thanks for reading this article. I hope this article will help you to configure Sendmail on CentOS and Red Hat systems.

    References:
    http://www.sendmail.com/
    http://www.sendmail.com/sm/open_source/docs/m4/intro_m4.html

    The post How to Install Sendmail Server on CentOS/RHEL 7/6 appeared first on TecAdmin.

    ]]>
    https://tecadmin.net/install-sendmail-server-on-centos-rhel-server/feed/ 10