How Do You Send an Email from a Postfix Email Server with A “Reply-to” Email Address of Your Choosing?

Problem scenario
You are using Linux. You want to send emails from your server directly (e.g., from the command prompt using telnet and helo commands) with a customized "Reply-To" email address. How do you do this so the recipient clicks "reply" the "To:" field will be pre-populated.

Prerequisite
Install Postfix. See one this posting if you are using Linux SUSE; see this posting if you have a CentOS/RedHat/Fedora distribution. If you have an Ubuntu or Debian distribution, we recommend trying to use the CentOS/RedHat/Fedora posting, but be prepared to deviate from the directions.

Procedures
1. Edit the /etc/postfix/main.cf file in three ways.
1.a. Find the "mydomain" stanza. Uncomment it out (remove the leading "#"). Set it to the domain you want like this (but replace continualintegration.com with the domain name that you want the "Reply-To" to have):
mydomain = continualintegration.com

1.b. Find the "inet_interfaces = all" stanza and uncomment it out (remove the leading "#").

1.c. Append this stanza to the very bottom of the file:
smtp_generic_maps = hash:/etc/postfix/generic

2. Edit (or create) this file /etc/postfix/generic so it has these stanzas (but replace continualintegration.com with the domain you want the "reply-to" to have, and "no-reply" with the destination user that you want the email address to have):

root@continualintegration.com   no-reply@continualintegration.com
@continualintegration.com       no-reply@continualintegration.com

3. Run this command to have the changes take effect: sudo postmap /etc/postfix/generic

An Alternative Way To Send Email
Another way to do this is with Python; to learn how to use Python and not install anything else, see this external posting.

Leave a comment

Your email address will not be published. Required fields are marked *