Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 256
  • Last Modified:

Mail with HTML

I have the following script and it sends text mail just fine, but when I send html in the body and receive it with MS Outlook Express, it just gives html code.  When I receive it with eudora 4, it gives the actual pictures etc.  It is RFC 1521.

unless (open(SENDMAIL, ">$filename")){
print "Error opening email file.";
}
print SENDMAIL "Content-type: text/html\n\n";
print SENDMAIL "From: $from\n";
print SENDMAIL "To: $to\n";
print SENDMAIL "Subject: $subj\n";
print SENDMAIL "Date: $thedate\n";
print SENDMAIL "\n";
print SENDMAIL "$body\n";
close SENDMAIL;

What do I need to add or change to make the Outlook Express convert the html to actual pictures?  It must have something to do with content-type:.
0
Lee5
Asked:
Lee5
  • 3
  • 2
1 Solution
 
helverCommented:
Try removing the second newline from the Content-type print statement.
0
 
Lee5Author Commented:
That does not make any difference.
0
 
b2piCommented:
Any chance you're running the HTML on a Unix box?

Secondly, I don't see how you're sending mail (you're writing to a file $filename, but what processing are you doing after closing the file?)

0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Lee5Author Commented:
Here is the entire script:

require "cgi-lib.pl";
require "ctime.pl";
&ReadParse(*input);
 $body = $input{'bod'};
 $from = $input{'email'};
 $to = $input{'to'};
 $subj = $input{'subj'};
 $thedate = &ctime(time);
print "Content-type: text/html\n\n";
 $filename = "C:\\exchsrvr\\imcdata\\Pickup\\uw$$.txt";
unless (open(SENDMAIL, ">$filename")){
 print "Error opening email file.";
}
print SENDMAIL "From: $from\n";
print SENDMAIL "To: $to\n";
print SENDMAIL "Subject: $subj\n";
print SENDMAIL "Date: $thedate\n";
print SENDMAIL "\n";
print SENDMAIL "$body\n";
close SENDMAIL;

$body is a html page.  If received in Eudora 4 the page shows up normally with all tables, pictures, etc.  In MS Outlook it shows only html code.
0
 
Lee5Author Commented:
It is on a NT box
0
 
b2piCommented:
What do you know.... there it is...

You're doing:

print "Content-type: text/html\n\n";
$filename = "C:\\exchsrvr\\imcdata\\Pickup\\uw$$.txt";
unless (open(SENDMAIL, ">$filename")){
    print "Error opening email file.";
}
print SENDMAIL "From: $from\n";

which print's the header to stdout (wherever that might be).  Instead, do


$filename = "C:\\exchsrvr\\imcdata\\Pickup\\uw$$.txt";
unless (open(SENDMAIL, ">$filename")){
    print "Error opening email file.";
}
print "Content-type: text/html\n\n";
print SENDMAIL "From: $from\n";


which will tell exchange that this really is html
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

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