Tuesday 23 July 2013

Setting up email piping

Mail Transfer Agent


A mail transfer agent (MTA) or mail relay is a software that transfers electronic mail messages from one computer to another using a client-server application architecture. An MTA implements both the client (sending) and server (receiving) portions of the Simple Mail Transfer Protocol. MTAs receive e-mail messages and recipient addresses from local users, remote hosts and deliver the messages to their destinations. Popular MTA available used on servers are exim, qmail, sendmail and postfix.

The MTAs are integral part of Messaging system. A message transfer agent receives mail from either another MTA or a MUA (Mail User Agent). The transmission details are specified by the Simple Mail Transfer Protocol (SMTP). When a recipient mailbox of a message is not hosted locally, the message is relayed, that is, forwarded to another MTA. Every time an MTA receives an email message, it adds a Received trace header field to the top of the header of the message, thereby building a sequential record of MTAs handling the message. The process of choosing a target MTA for the next hop is also described in SMTP, but can usually be overridden by configuring the MTA software with specific routes.

Prerequisites for email piping


There are some prerequisites that needs to be fulfilled before configuring email piping on the server:

The first and the most important is that, the mail server must be installed on the same Linux server on which the helpdesk is installed.








Kayako does not support email piping on Windows server.


Once the first prerequisite is met, the others follow:

The email address setup as email queue should be a virtual email address without any inbox associated with it.

The permissions of 755 should be set on the path leading to "/../console/index.php/" file.

PHP interpreter path: By default the path for PHP interpreter in the '/../console/index.php' file is set as '/usr/bin/php'. This is the path of PHP executable file that is used by mail parser script to process the emails coming to the Piped email address. If the path of the PHP interpreter is different than the default one specified in file, you will need to edit the '/../console/index.php' file accordingly.  The path of the PHP interpreter can be found on the server by the following command:












#which php








Per the output mentioned in the image, the PHP interpreter's path in the 'console/index.php' file of the help desk needs to be edited to as '/usr/local/bin/php'.

Setting up e-mail piping on different MTAs


An e-mail queue can be created which can handle e-mails that are piped into the system. Email piping is the automatic pushing of an e-mail by the server into the helpdesk installation files. This is done by forwarding an e-mail alias to a script within the helpdesk installation. The setting up of email aliases may vary depending upon the MTA being used on the server. Every MTA support email aliasing. As the email are aliased to a helpdesk script, the full path to the script must be executable by others. This does not open up any security hole on the server. The path to PHP binary may require to be modified according to location of PHP binary on the server. The issue will be discussed in On-The-Floor session under Email Piping.

Email piping in Qmail


This procedure explains how to set up e-mail piping in Qmail.

  • Via SSH, we need to manually edit the file /var/qmail/mailnames/company.com/.qmail-support, where support is the e-mail alias name (support@yourdomain.com). The .qmail-support is the name of the file we are editing, and in it we will place the pipe command.














| /home/httpd/vhosts/company.com/httpdocs/full/path/to/console/index.php







  • This command will pipe incoming e-mails to the specified location. Save the file.


Setting up e-mail piping in Sendmail


This procedure explains how to set up e-mail piping manually using the Sendmail mail transport system:

  • Open the aliases (/etc/aliases) file for editing.

  • Assuming that we creating aliases for the e-mail addresses support@company.com and services@company.com, we will create the corresponding entries in the aliases file as follows:














support: | /full/path/to/console/index.php

sales:   | /full/path/to/console/index.php






Now we must ensure we have created an e-mail queue within the administrator control panel, so that the mail parser will accept the incoming e-mail messages. If we are still facing the issue with email piping, check the SMRSH restrictions.

SMRSH Restrictions: Certain Sendmail systems are configured with Sendmail Restricted Shell enabled to prevent the execution of any malicious programs or scripts. If we receive a bounce message with detailing a SMRSH failure, then we will need to configure the mail parser with SMRSH in the following way:

  • Find the SMRSH path, run the command man smrsh as shown below.

  • The path to SMRSH is listed in the second paragraph. Through the information displayed after executing this command, we now know that SMRSH files should go under "/etc/smrsh".

  • We will now need to create a symlink to our "/console/index.php" under the directory "/etc/smrsh".


The command syntax is:












ln -s /full/path/to/console/index.php /etc/smrsh/index.php







  • Once the symlink has been created, we should change the alias file contents as follows:














From: support: | /full/path/to/console/index.php

To:   support: | /etc/smrsh/index.php







  • Once the aliases file has been edited and saved, we will need to execute the newaliases command.


Setting up e-mail piping in Postfix


This procedure explains how to set up e-mail piping manually using the Postfix mail transport system.

  • Open the /etc/postfix/aliases file for editing.

  • Assuming that we are creating aliases for the e-mail addresses sales@company.com and support@company.com, we will create the corresponding entries in the aliases file as follows:














support: | /full/path/to/console/index.php

sales:   | /full/path/to/console/index.php







  • Once the aliases file has been edited and saved, we will need to execute the newaliases command.


Setting up e-mail piping in Exim


This procedure explains how to set up e-mail piping manually using the EXIM mail transport system.

  • Open the /etc/valiases/company.com file for editing.

  • Assuming that we are creating aliases for the e-mail addresses sales@company.com and support@company.com, we will create the corresponding entries in the aliases file as follows:














support: | /full/path/to/console/index.php

sales:   | /full/path/to/console/index.php







  • Once the aliases file has been edited and saved, we will need to execute the newaliases command.


Setting up e-mail piping in cPanel


Many hosting providers use cPanel as their control panel. They allow limited access to users so that the users may manage their domain from graphical interface.

  • Login to your cPanel control panel.

  • From the main menu, select the Mail icon and choose the Forwarder option.




  • Click on Add Forwarder to create a new forwarder.




  • You will be presented with a series of fields that will allow you to forward an e-mail alias (an alias being the “support” in the e-mail address “support@yourdomain.com”.




  • In the Address to Forward field, enter the e-mail alias. If you wish to create an e-mail forwarder for the address support@yourdomain.com, the alias here should be support.

  • In the Pipe to a Program, enter the location to which you want to forward the incoming mail to. This location has to be the pipe command to the absolute path of the location of your ../console/index.php file (the file that accepts incoming e-mail pipes). This will pipe incoming e-mails to the specified location.

No comments:

Post a Comment