• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 252
  • Last Modified:

Aliasing message with To: field...

I have an email address with my cellular phone that I need my work address forwarded to. The only problem is, my cellular phone email address doesn't accept any messages unless they are addressed specifically to their address (not forwarded).

Example: Only works if addressed to '4435551212@cell1.textmsg.com' - Doesn't work if drummond@connext.net is forwarded to '443555....' because it goes to their system looking like drummond@connext.net


So basically, I need to setup some sort of forwarding that makes messages appear as if they are addressed to one address, when really they are addressed to another. Any ideas?? Can this be done with Sendmail? Relaying? Masquerading?

Thanks!
0
drummond
Asked:
drummond
  • 5
  • 2
1 Solution
 
jlevieCommented:
Other than a custom rule in your sendmail.cf, I don't think you could theres any way to change the "To" line. Sendmail futzes with the envelope to get the message delivered, but headers like "To" "Subject", etc are the province of the sending mail client. In general sendmail doesn't care what's in the those headers (or even if they are present).

The easiest way I can think of would be to set up an alias that accepts the message, rewrites the "To:" line and mails it. A small perl script that replaces the "To" line and mails it out can be set up as an alias like:

username:  |/path-to-script/cellmailer

I've used something very similar to resend emailed alerts as email to a paging service on my cell phone.
0
 
jlevieCommented:
A minute or so after I hit submit I realized there's a trivial way to handle your case. I needed a perl script because I had to do more serious modification of the message. All you need is to change the "To" line which you ought to be able to do with an alias like:

username:  | (sed -e "s/^To:.*/To: cell-page@where/" | mail -w cell-page@where)

This works on Solaris, you might need to change "mail -w" to whatever your OS would use to send a message from the command line.
0
 
jlevieCommented:
I'm marking this as answered per the comments.
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
drummondAuthor Commented:
I didn't exactly have any luck with the alias file. I don't think I had the syntax entirely right.

However, my first solution was to take a Perl route as well. I wrote a script that basically did the same thing - re-addressed the email and sent it out again. It almost took down our system twice.

I found that when it re-sent the email to my cell phone, it 1) Also sent a copy to anyone who had been carbon copied on the original messages AND 2) this was very bad if someone typed in a wrong address for a carbon copy.

For example, someone would send to drummond@connext.net and carbon copy "brokenmail@aol.com". Well if "brokenmail@aol.com" doesn't exist, it sent the thing 200 times, totally clogging up my ISP's system.

I don't know why it happened, but I decided to look for a solution out here. I was hoping for some sort of built in sendmail command so I knew it couldn't be as destructive as the Perl solution was.

Thanks for the post! If I end up sticking with the Perl, I will award you the points.
0
 
jlevieCommented:
Ah, you do need to more than just change the "To:" field. The perl script I use, mentioned in the first comment, does exactly that. It reads the message and trashes all of the header lines except "Subject" and the "To" (which it re-writes. Those two lines and the body are sent via email as a page. Note that sendmail doesn't care one bit what the headers are, and will quite happily deliver an email with none of the "standard" headers.

Just in case you don't know... You can tell where the headers end on a Unix system by reading and processing lines until you see a blank line. The spec requires it to be there.

The easiest way of doing this is to have perl write a temp file containing the new message and then use the system call to ship it out to your mail system. On Solaris I use:

system "mail -w pager\@somdom.com <$tmpf"

Your "mail" command & args might be different. This happens to make debugging the script a trivial task. Comment out the system call and don't unlink the tempfile when the script exits and you can see exactly what the re-mailed message will look like. When it's right you can test by manually invoking what the system call would have done.

0
 
drummondAuthor Commented:
You're exactly right! I didn't think to throw out all the information in the header - that's brilliant. And who knew it could be so easy! Consider the points yours - Well earned!
0
 
jlevieCommented:
Thanks for the compliment...
0

Featured Post

[Webinar] Improve your customer journey

A positive customer journey is important in attracting and retaining business. To improve this experience, you can use Google Maps APIs to increase checkout conversions, boost user engagement, and optimize order fulfillment. Learn how in this webinar presented by Dito.

  • 5
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now