It's also displaying any HTML instead of rendering it in spite of my content-type, which leads me to believe it's ignoring that as well.
I've tested and re-tested, it's coming in fine with a subject and all other headers when I receive it via Eudora or web-based programs such as iMail. In the code below I've tried eliminating the \r so it just reads \n, and have tried moving the fields around ('From' first does nothing at all.)
Sadly, I have no access to mail or error logs.
Any thoughts?
open (MAIL,"¦ $mailprog -t") ¦¦ &error("Cannot start $mailprog $!");
print MAIL "To: $data{$email_field}\r\n";
print MAIL "From: $real_recipient\r\n";
print MAIL "Subject: $subject\r\n";
print MAIL "MIME-Version: 1.0\r\n";
print MAIL "Content-Type: text/html; charset=US-ASCII\r\n";
print MAIL "X-Priority: 3\r\n";
print MAIL "X-MSMail-Priority: Normal\r\n\r\n";
print MAIL "$custopener";
print MAIL "$body";
print MAIL "$custcloser";
close (MAIL);
I always have to switch header order around and arrived at a best possible, I think yours is the same but I am not on my main machine at the moment and have no code examples here.
the order of MIME-Version: and Content-Type always seemed to be an issue but I think your example is the same as I put them. I will take a look at some code when the relative crashed in my office wakes up. :)
this is a php snippet but the same rules apply
$headers = '';
$headers .= 'To: ' . $row[0] . "\r\n";
$headers .= "From: " . $corpname . " <" . $sourceemail . ">\r\n";
$headers .= 'Subject: ' . $subject . "\r\n";
$headers .= "Return-Path: " . $sourceemail . "\r\n";
$headers .= "Reply-To: " . $sourceemail . "\r\n";
$headers .= "Content-type: text;\r\n";
$headers .= "Mime-Version: 1.0\r\n";
$headers .= "X-Mailer: Company Mailer\r\n";
these are fed to an email parser that uses this line to open a pipe to sendmail
$pipe_handle = popen( "/usr/lib/sendmail -t -f $whowhere", "w" )
I haven't had any trouble with this order, I remember the Mme had to be moved around a bunch of times
open (MAIL,"¦ $mailprog -t") ¦¦ &error("Cannot start $mailprog $!");
print MAIL "To: $data{$email_field}\r\n";
print MAIL "From: $real_recipient\r\n";
print MAIL "Content-Type: text/html; charset=US-ASCII\r\n";
print MAIL "MIME-Version: 1.0\r\n";
print MAIL "Subject: $subject\r\n";
print MAIL "X-Priority: 3\r\n";
print MAIL "X-MSMail-Priority: Normal\r\n";
print MAIL "$custopener";
print MAIL "$body";
print MAIL "$custcloser";
close (MAIL);
Also, when using "text/html" you should also define the "bit encoding" for proper rendering.
do you have the option to look at the headers as they appeared on the message the client received?
Only a forward - from what I can gather Outlook 2003 is not recognizing the headers as headers at all. It's shoving everything but the TO: down into the message body. Since content-type is not being read as a header, the HTML is rendering in the body as if it were plain text.
- There are two subroutine instances in this script, identical in the order they send but only difference is in the TO, FROM, and intro text values. One goes to company, one to submittor. Changing the \r\n to just "\n" apparently fixed one instance but not the other, but they are identical!
- "Till I get it right" - as said I've used this for years with no reported problems, but as jatar_k says I have been on a few servers where the location of fields has made a difference. I will return this to the sample posted by Dr Doc and give it a shot.
- remove double returns? I was under the impression it's the double returns that indicate end-of-headers?
Also, when using "text/html" you should also define the "bit encoding" for proper rendering.
Will do, although what encoding? :-D Sec. 6 of RFC 2045 seems to indicate it defaults to 8bit, but will specify it anyway as below.
Revised output:
open (MAIL,"¦ $mailprog -t") ¦¦ &error("Cannot start $mailprog $!");
print MAIL "To: $data{$email_field}\r\n";
print MAIL "From: $real_recipient\r\n";
print MAIL "Content-Type: text/html; charset=US-ASCII\r\n";
print MAIL "Content-Transfer-Encoding: 8bit\r\n";
print MAIL "MIME-Version: 1.0\r\n";
print MAIL "Subject: $subject\r\n";
print MAIL "X-Priority: 3\r\n";
print MAIL "X-MSMail-Priority: Normal\r\n";
print MAIL "$custopener";
print MAIL "$body";
print MAIL "$custcloser";
close (MAIL);
Will let you know how it goes. :-)
I am editing using HomeSite and exclusively save in Unix file format, not PC format, which affects script execution (sometimes) but shouldn't affect a print to mail. Bizzare, anyway thanks everyone for your help.