MoonPoint Support Logo

 


Shop Amazon Warehouse Deals - Deep Discounts on Open-box and Used ProductsAmazon Warehouse Deals



Advanced Search
February
Sun Mon Tue Wed Thu Fri Sat
 
21
         
2016
Months
Feb


Sun, Feb 21, 2016 10:50 pm

Testing email forwarding on a Linux system with mailx

I needed to have a password reset email for an online account sent to an email address other than the one designated for that account, so I set up forwarding on the server where the designated account resided by using a .forward file to forward the message on to the email address where I wanted it to go as I've done in the past when I needed to forward mail from a Linux system that uses Sendmail email program.. I wanted the email to go to the inbox for the account it would normally be delivered to, but also be forwarded to another account as well, but the email message wasn't forwarded.

I had created the .forward file in the home directory for the relevant account with a command similar to the following:

echo '\jdoe, johndoe@example.com' > /home/jdoe/.forward

I created the forward file while logged into the relevant user account, so the file was owned by that account. The \jdoe ensures that the email goes to the inbox for the account itself. Following it by a comma and another email address results in the email also going to that second address.

However, the email reset only went to the inbox on the system where I created the .forward file. So I used the mailx command to send some test messages. You can use the following syntax to send messages with mailx: mailx -s subject email_address where subject is the subject you want the message to have and email_address is the email address you wish to use for the recipient. When you hit Enter, you can enter text for the body of the message. Hit Ctrl-D to complete the message. You will then see "EOT" and the message will be sent. E.g., I used the following:

$ mailx -s 'Email forwarding test' jdoe
Just a test
EOT

You can also put whatever text you wish to put in the body of the message in a text file and include it with < file where file is a text file you wish to use for the body of the message. E.g.: mailx -s 'Forwarding Test' jdoe < mymessage.txt.

But the test messages I sent didn't reach the forwarding address. During testing, I realized that because I hadn't changed the default permissions for the .forward file, forwarding wasn't actually occurring. When I looked at the permissions on the file, I saw the following:

$ ls -l .forward
-rw-rw-r--. 1 jdoe jdoe 28 Feb 21 22:21 .forward

The file permissions should be 644 whereas they were 664. I.e., not only did the owner have read and write permissions, but so did the group. If group has write permission rather than just read permission, then email will not be forwarded by sendmail. When I changed the permissions with chmod 644 .forward, forwarding worked and I was able to receive test messages in the inbox for the account on the system, but also at the remote inbox.

[/network/email/sendmail] permanent link

Once You Know, You Newegg AliExpress by Alibaba.com

Shop Amazon Local - Subscribe to Deals in Your Neighborhood

Valid HTML 4.01 Transitional

Privacy Policy   Contact

Blosxom logo