mail – TecAdmin https://tecadmin.net How to guide for System Administrator's and Developers Tue, 05 Apr 2022 04:40:38 +0000 en-US hourly 1 https://wordpress.org/?v=6.1.1 Postfix Forward Incoming Emails to Other Email Account https://tecadmin.net/postfix-forward-emails-to-other-email-account/ https://tecadmin.net/postfix-forward-emails-to-other-email-account/#respond Thu, 13 Aug 2020 09:13:14 +0000 https://tecadmin.net/?p=22555 I am configuring my Linux system to accept incoming emails and forward them to needed email accounts. For this setup, the Ubuntu operating system is used with the postfix mail server. We can configure Postfix as mail forwarding server using the virtual_alias_maps settings. This tutorial will help you to set up a postfix server to [...]

The post Postfix Forward Incoming Emails to Other Email Account appeared first on TecAdmin.

]]>
I am configuring my Linux system to accept incoming emails and forward them to needed email accounts. For this setup, the Ubuntu operating system is used with the postfix mail server. We can configure Postfix as mail forwarding server using the virtual_alias_maps settings.

This tutorial will help you to set up a postfix server to forward the email to other email accounts.

Setup Mail Forwarding in Postfix

Forwarding emails to remote mailboxes via Postfix does not require local mailboxes. Any email received by the Postfix will be routed to remote mailboxes based on configuration.

Below example configuration will help you to configure example.com as mail forwarding domain on Postfix.

Edit Postfix main.cf in editor:

sudo vi /etc/postfix/main.cf 

Add your mail forwarding domain to virtual_alias_domains and a configuration file with routing rules with virtual_alias_maps. You can add multiple virtual_alias_domains with space-separated.

virtual_alias_domains = example.com tecadmin.net
virtual_alias_maps = hash:/etc/postfix/virtual

Next create and edit /etc/postfix/virtual file in editor:

sudo vi /etc/postfix/virtual 

Now add the Postfix email forwarding rules as per your requirements. Below is some example:

  1. Forward rahul@example.com emails to rahul@remote.example.com
    rahul@example.com       rahul@remote.example.com 
    
  2. Forwarding all the emails sent to any email id for domain example.com to catch-all@remote.example.com
    @example.com       catch-all@remote.example.com 
    
  3. Forward incoming emails to support@example.com to the local Unix root account.
    support@example.com       root
    

Save and close the file. Next, create a hash file of the virtual and start postfix service.

postmap /etc/postfix/virtual 
service postfix restart 

Conclusion

In this tutorial, you have learned to configured Postfix to forward emails to other email accounts.

The post Postfix Forward Incoming Emails to Other Email Account appeared first on TecAdmin.

]]>
https://tecadmin.net/postfix-forward-emails-to-other-email-account/feed/ 0
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 Postal Mail Server on Ubuntu 16.04 & 14.04 https://tecadmin.net/install-postal-mail-server-on-ubuntu/ https://tecadmin.net/install-postal-mail-server-on-ubuntu/#comments Fri, 19 May 2017 16:34:07 +0000 https://tecadmin.net/?p=12584 Postal is a complete and fully featured mail server for use by websites & web servers. Postal can be a better alternative of Sendgrid, Mailchimp, Mailgun and other similar SMTP servers. You can easily host Postal mail server on your system and use this as SMTP server for sending application emails, bulk emails, newsletters etc. [...]

The post How to Install Postal Mail Server on Ubuntu 16.04 & 14.04 appeared first on TecAdmin.

]]>
Postal is a complete and fully featured mail server for use by websites & web servers. Postal can be a better alternative of Sendgrid, Mailchimp, Mailgun and other similar SMTP servers. You can easily host Postal mail server on your system and use this as SMTP server for sending application emails, bulk emails, newsletters etc. This tutorial will help you to install Postal Mail server on Ubuntu 16.04 & 14.04 LTS. You can also try the same Debian and Linuxmint and share your feedback in comments.

Prerequisites

For installation of Postal mail server on your system, you must have following prerequisites installed on your system. This tutorial will help you to install them.

  • Ruby 2.3 or higher
  • MySQL or MariaDB database server
  • RabbitMQ server
  • Node.js (for javascript compilation)
  • Git (for accessing the repository)

Step 1 – Install Basic Packages

First, start with the initial package installations on your system. Use below commands to install Git, MariaDB(MySQL) database server and Nginx web server with some other dependencies.

$ sudo apt-get install python-software-properties  software-properties-common
$ sudo apt-get install git nginx mariadb-server build-essential libmysqlclient-dev 

Step 2 – Install Node.js

Now, install the latest Nodejs on your system. Use the following commands to install Nodejs 7 on your system or visit this tutorial to install latest available version.

$ curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash -
$ sudo apt-get install nodejs

Step 3 – Install Ruby 2.3

After installing Node.js, install Ruby version 2.3 or higher version on your system. First use following commands to add Ruby languege PPA in your system.

$ sudo apt-add-repository ppa:brightbox/ruby-ng -y
$ sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8

Now, use the below commands for installing Ruby 2.3 on system.

$ sudo apt-get update
$ sudo apt-get install -y ruby2.3 ruby2.3-dev

Step 4 – Install RabbitMQ Server

You also needs to install RabbitMQ server on your system for messaging. Use following commands enable Erlang packages PPA.

$ wget https://packages.erlang-solutions.com/erlang-solutions_1.0_all.deb
$ sudo dpkg -i erlang-solutions_1.0_all.deb

Also enable the RabbitMQ server PPA in your system.

$ echo 'deb http://www.rabbitmq.com/debian/ testing main' | sudo tee /etc/apt/sources.list.d/rabbitmq.list
$ wget -O- https://www.rabbitmq.com/rabbitmq-release-signing-key.asc | sudo apt-key add -

Now, you can install RabbitMQ Server package on your system using the following command. This will install all of its dependencies as well.

$ sudo apt-get update
$ sudo apt-get install erlang erlang-nox rabbitmq-server

Step 5 – Create Database in MySQL

First, create a database in your MySQL server, Also create a database user for accessing database with the Postal mail server. Also, add a grant that permits Postal to manage all databases that are prefixed with postal-.

$ mysql -u root -p
Enter password:*******

mysql> CREATE DATABASE postal CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci;
mysql> GRANT ALL ON `postal`.* TO `postal`@`127.0.0.1` IDENTIFIED BY "passw0rd";
mysql> GRANT ALL ON `postal-%`.* TO `postal`@`127.0.0.1` IDENTIFIED BY "passw0rd";
mysql> FLUSH PRIVILEGES;

Step 6 – Create RabbitMQ VirtualHost

In this step, add a VirtualHost in RabbitMQ server and create a user account to access it with application.

$ rabbitmqctl add_vhost /postal
$ rabbitmqctl add_user postal passw0rd
$ rabbitmqctl set_permissions -p /postal postal ".*" ".*" ".*"

Step 7 – Install Postal Mail Server

At this point, You have completed all requirements for Postal installation. Let’s start with the user creation for Postal setup. Create a account named postal with following command.

$ sudo useradd -r -m -d /opt/postal -s /bin/bash postal
$ sudo setcap 'cap_net_bind_service=+ep' /usr/bin/ruby2.3

Now, clone the postal source code on Github using following command. And add a soft link of the Postal binary file under /usr/bin/ directory to access command globally.

$ sudo -i -u postal git clone https://github.com/atech/postal /opt/postal/app
$ ln -s /opt/postal/app/bin/postal /usr/bin/postal

To configure postal, you’ll need to have bundler and procodile installed on your system. Install them both:

$ sudo gem install procodile bundler

Now, switch to postal user and complete all the installations with following commands.

$ su - postal
$ postal bundle /opt/postal/app/vendor/bundle
$ postal initialize-config
$ postal initialize
$ postal start

Step 8 – Create Postal Admin User

Now run the postal make-user user to create first Postal administrator account. This account will be used latest to login on Potal dashboard.

$ postal make-user 

Postal User Creator
Enter the information required to create a new Postal user.
This tool is usually only used to create your initial admin user.

E-Mail Address      : admin@tecadmin.net
First Name          : Rahul
Last Name           : Kumar
Initial Password:   : *********

User has been created with e-mail address admin@tecadmin.net

Step 9 – Check Postal Running Status

At this stage, your have a running Postal server. To make sure everything is working properly use the following command. You will find following 5 services there. Make sure all the services are in running stage.

$ postal status

The command output will be as below.

Procodile Version   1.0.16
Application Root    /opt/postal/app
Supervisor PID      28022
Started             2017-05-16 18:41:53 +0530

|| web
|| Quantity            1
|| Command             bundle exec puma -C config/puma.rb
|| Respawning          5 every 3600 seconds
|| Restart mode        usr1
|| Log path            none specified
|| Address/Port        none
|| => web.1            Running      18:41        pid:28028    respawns:0      port:-        tag:-

|| worker
|| Quantity            1
|| Command             bundle exec rake postal:worker
|| Respawning          5 every 3600 seconds
|| Restart mode        start-term
|| Log path            none specified
|| Address/Port        none
|| => worker.1         Running      18:41        pid:28030    respawns:0      port:-        tag:-

|| cron
|| Quantity            1
|| Command             bundle exec rake postal:cron
|| Respawning          5 every 3600 seconds
|| Restart mode        term-start
|| Log path            none specified
|| Address/Port        none
|| => cron.1           Running      18:41        pid:28032    respawns:0      port:-        tag:-

|| smtp
|| Quantity            1
|| Command             bundle exec rake postal:smtp_server
|| Respawning          5 every 3600 seconds
|| Restart mode        usr1
|| Log path            none specified
|| Address/Port        none
|| => smtp.1           Running      18:41        pid:28034    respawns:0      port:-        tag:-

|| requeuer
|| Quantity            1
|| Command             bundle exec rake postal:requeuer
|| Respawning          5 every 3600 seconds
|| Restart mode        term-start
|| Log path            none specified
|| Address/Port        none
|| => requeuer.1       Running      18:41        pid:28036    respawns:0      port:-        tag:-

Step 10 – Setup NGINX for Postal

Postal provides a Nginx configuration file. Just copy this file to your Nginx server. You can simply replace default Nginx configuration file or create a new file.

$ cp /opt/postal/app/resource/nginx.cfg /etc/nginx/sites-available/default

Postal default works with SSL only. So create a self-signed SSL to access Postal dashboard or you can get a free valid certificate from Let’s Encrypt.

$ sudo mkdir /etc/nginx/ssl/
$ sudo cd /etc/nginx/ssl/
$  openssl req -x509 -nodes -newkey rsa:4096 -keyout postal.key -out postal.crt

Finally, reload Nginx web server.

$ sudo service nginx reload

Now access your server with https. You will get Postal dashboard login screen. Enter your administrator account details created in step 8.

Step 11 – Configure Postal Dashboard

At this point, You have a running Postal server. Now you need to configure this to send emails. First, you need to understand the setup. There are three main parts

  • Organization => You can create multiple organizations, eg one organization for one client.
  • Mail server accounts => Each organization can have multiple mail server account. You can keep them in live or development mode. For eg, an organization can assign one mail server to each production team.
  • Domains => Each mail servers can have multiple domains. Remember that Postal will accept emails have from address for domains added here and verified.

Create Organization

So let’s create your first organization after login. Click on Create the first organization button. Enter the name of the organization and short name in the input box.

Build Mail Server

You will be automatically switched to the newly created organization, Now click on build your first mail server button. Input the name of your mail server, short name, and mode of the mail server. There are two type of mode available

  • Live => The emails will work properly and reached to destination.
  • Development => The emails sent will show in Postal dashboard but they actually not delivered to end users

Add Domains

Now add your first domain from which you need to send emails. This will show you the DNS settings required to update for the added domain. Update all settings in DNS server and complete this step.

Create Credentials

You also need to create credentials for your mail server. There are two types of creadentials.

  • SMTP => These credential will required to send emails through SMTP protocol, For example linux mail command, PHPMailer etc.
  • API => These are required to send mails through HTTP api.

Step 12 – Testing Postal with Client

Postal provides its client libraries for multiple programming languages. Download the required library from below link and test the setup.

https://github.com/atech

The post How to Install Postal Mail Server on Ubuntu 16.04 & 14.04 appeared first on TecAdmin.

]]>
https://tecadmin.net/install-postal-mail-server-on-ubuntu/feed/ 4
How to Transfer Mailboxes Between IMAP Servers with Imapsync https://tecadmin.net/transfer-mailboxes-with-imapsync/ https://tecadmin.net/transfer-mailboxes-with-imapsync/#comments Sat, 13 May 2017 03:25:59 +0000 https://tecadmin.net/?p=12615 What is Imapsync? Imapsync is an IMAP transfer tool used for transferring mailboxes and emails from one IMAP server to another IMAP server. Imapsync application is a command line tool that allows incremental and recursive IMAP transfers from one mailbox to another, both anywhere on the internet or in your local area network. Installation of [...]

The post How to Transfer Mailboxes Between IMAP Servers with Imapsync appeared first on TecAdmin.

]]>
What is Imapsync?

Imapsync is an IMAP transfer tool used for transferring mailboxes and emails from one IMAP server to another IMAP server. Imapsync application is a command line tool that allows incremental and recursive IMAP transfers from one mailbox to another, both anywhere on the internet or in your local area network.

Installation of Imapsync

Imapsync tools is vailable for various plateform. Use one the the following tutorial as per your operating system.

For installation on other platforms visit here.

Transfer Mailboxes with Imapsync

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 Transfer Mailboxes Between IMAP Servers with Imapsync appeared first on TecAdmin.

]]>
https://tecadmin.net/transfer-mailboxes-with-imapsync/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
How to Install and Use Imapsync on CentOS & Fedora https://tecadmin.net/use-imapsync-on-centos/ https://tecadmin.net/use-imapsync-on-centos/#comments Sat, 06 May 2017 03:22:22 +0000 https://tecadmin.net/?p=12623 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 CentOS & Fedora 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 – Install Imapsync

Imapsync package is available under EPEL package repository. First make sure you have added EPEL on your system or install it first.

$  sudo yum install epel-release

Now, install imapsync package using following command.

$ sudo yum install imapsync

At this stage, your system is ready for migration all data from one email account to other email accounts using IMAP.

Step 2 – 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 CentOS & Fedora appeared first on TecAdmin.

]]>
https://tecadmin.net/use-imapsync-on-centos/feed/ 3
How to Setup Mail Forwarding in Postfix https://tecadmin.net/setup-mail-forwarding-in-postfix-on-linux/ https://tecadmin.net/setup-mail-forwarding-in-postfix-on-linux/#comments Tue, 05 Jan 2016 05:56:31 +0000 https://tecadmin.net/?p=9547 Postfix is widely used Mail Transfer Agent (MTA) server, which provides to send, receive and forward emails over network. This tutorial will help you to configure your Postfix server to forward emails. Install Postfix MTA We are assuming that you already have postfix installed and configured on your system. Or you can use following commands [...]

The post How to Setup Mail Forwarding in Postfix appeared first on TecAdmin.

]]>
Postfix is widely used Mail Transfer Agent (MTA) server, which provides to send, receive and forward emails over network. This tutorial will help you to configure your Postfix server to forward emails.

Install Postfix MTA

We are assuming that you already have postfix installed and configured on your system. Or you can use following commands to install Postfix on Linux box according to your operating system.

On Debian Based Systems

$ sudo apt-get update
$ sudo apt-get install postfix

On RHEL Based Systems

# yum install postfix

On OpenSUSE Systems

# zypper in postfix

After installation make sure Postfix is running on your system. Default postfix used standard port 25. Use the following commands to check that your system is listening on port 25 or not.

# netstat -tulpn | grep 25

tcp    0   0 0.0.0.0:25    0.0.0.0:*         LISTEN      4398/master
tcp6   0   0 :::25         :::*              LISTEN      4398/master

Configure Email Forwarding in Postfix

Let’s start with email forwarding configuration in Postfix configuration file (/etc/postfix/main.cf). Edit this file and add/edit the following configurations. Change example.com and example.net domain names with your domain name

virtual_alias_domains = example.com example.net
virtual_alias_maps = hash:/etc/postfix/virtual

After making any changes in configuration files make sure to restart Postfix service.

Email Forwarding Examples

/etc/postfix/virtual is the file where we will add email forwarding rules. Let’s starts begin with the email forwarding rules.

1 – Forward all emails sent to info@example.com and info@example.net to rahul@myemail.com.

info@example.com rahul@myemail.com
info@example.net rahul@myemail.com

2 – Forward support@example.com emails to rahul@myemail.com and admin@myemail.com

support@example.com rahul@myemail.com admin@myemail.com

3 – Forward any email sent to @example.com domain to rahul@myemail.com. Also forward any email sent to @example.net domain to rahul@myemail.com as well as admin@myemail.com

@example.com rahul@myemail.com
@example.net rahul@myemail.com admin@myemail.com

Verify Setup

Let’s verify all settings by sending emails to @example.com and @example.net domain email accounts.

The post How to Setup Mail Forwarding in Postfix appeared first on TecAdmin.

]]>
https://tecadmin.net/setup-mail-forwarding-in-postfix-on-linux/feed/ 3
5 Ways to Send Email From Linux Command Line https://tecadmin.net/ways-to-send-email-from-linux-command-line/ https://tecadmin.net/ways-to-send-email-from-linux-command-line/#comments Mon, 11 May 2015 12:46:16 +0000 https://tecadmin.net/?p=2899 We all know the importance of emails these days for information transfer. There are many free emails service providers which we used for use like Gmail, Yahoo, RediffMail etc, which provides a web interface for sending and receiving emails. But this is not enough, sometimes we also required to send emails from system command line. [...]

The post 5 Ways to Send Email From Linux Command Line appeared first on TecAdmin.

]]>
We all know the importance of emails these days for information transfer. There are many free emails service providers which we used for use like Gmail, Yahoo, RediffMail etc, which provides a web interface for sending and receiving emails. But this is not enough, sometimes we also required to send emails from system command line. This tutorial will provide you multiple ways to send emails from the Linux command line. This is useful for sending email through our shell scripts, cronjobs etc.

email-banner

There are various ways to send emails from the command line but here I am sharing few options used by most users. You can use anyone option given below to send email from Linux command line.


1. Using ‘sendmail’ Command

Sendmail is a most popular SMTP server used in most of Linux/Unix distribution. Sendmail allows sending email from command line. Use below instructions to send email using ‘sendmail‘ command.

Created a file with email content:

cat /tmp/email.txt 

Subject: Terminal Email Send

Email Content line 1
Email Content line 2

Subject: line will be used as subject for email.

Now send email using the following command.

sendmail user@example.com  < /tmp/email.txt 

Read more: Install and Configure Sendmail on CentOS/RHEL


2. Using ‘mail’ Command

mail command is most popular command to send emails from Linux terminal. Use few of below examples to send an email.

mail -s "Test Subject" user@example.com < /dev/null 
  • -s is used for defining subject for email.

Also, you can send an attachment with this command. Use -a for mailx and -A for mailutils.

mail -a /opt/backup.sql -s "Backup File" user@example.com < /dev/null 
  • Here -a is used for attachments. Use -A for debian based systems, which uses mailutils package.

You may face issue: Bash: mail: command not found

Also, we can add comma separated emails to send the email to multiple recipients together.

mail -s "Test Email"  user@example.com,user2@example.com < /dev/null 

3. Using 'mutt' command

Mutt is basically used for reading emails from Linux terminal from local user mailboxes, also useful to read emails from POP/IMAP servers. Mutt command is little similar to mail command. Use few of below examples to send an email.

mutt -s "Test Email" user@example.com < /dev/null 

Send an email including an attachment

mutt  -s "Test Email" -a /opt/backup.sql user@example.com < /dev/null 

4. Using 'SSMTP' Command

sSMTP allows users to send emails from SMTP server from Linux command line. For example to send an email to user admin@example.com use following command. Now type your subject of the email as below with keyword Subject. After that type your message to be sent to the user, After finishing your message press CTRL+d (^d) to send the email.

ssmtp admin@example.com 
Subject: Test SSMTP Email
Email send test using SSMTP
via SMTP server.
^d

Read more: How to Setup SSMTP Server on Linux


5. Using 'telnet' Command

As per my experience, all system administrators use telnet command to test remote port connectivity test or login to the server remotely. Most of the newbie in Linux doesn't know that we can send email using telnet also, which is the better way to troubleshoot email sending problems. Below is an example of email sending.

Red marked text is the user input and remaining is the responses of that commands.

telnet localhost smtp


Trying 127.0.0.1...
Connected to localhost.localdomain (127.0.0.1).
Escape character is '^]'.
220 fbreveal.com ESMTP Sendmail 8.13.8/8.13.8; Tue, 22 Oct 2013 05:05:59 -0400
HELO yahoo.com
250 tecadmin.net Hello tecadmin.net [127.0.0.1], pleased to meet you
mail from: sender@tecadmin.net
250 2.1.0 sender@tecadmin.net... Sender ok
rcpt to: myemail@ymail.com
250 2.1.5 myemail@ymail.com... Recipient ok
data
354 Enter mail, end with "." on a line by itself
Hey
This is test email only

Thanks
.
250 2.0.0 r9M95xgc014513 Message accepted for delivery
quit
221 2.0.0 fbreveal.com closing connection
Connection closed by foreign host.

Bonus Tips - Attach a file to Email from Shell

You can also send email with a attachment from Linux shell. Use -A option to provide a file path with mail command.

mail -s "Test Mail" -r mail-from@example.net -A attach.zip mail-to@example.com <<< "This is mail body" 

Thank you for using this article. We will add more ways soon with this list. We also request you to help me with more commands which you know and not listed above.

The post 5 Ways to Send Email From Linux Command Line appeared first on TecAdmin.

]]>
https://tecadmin.net/ways-to-send-email-from-linux-command-line/feed/ 37
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