Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

'HTML format emails' as opposed to 'TEXT format emails' 2

Status
Not open for further replies.

rspratt

MIS
Oct 12, 2000
4
GB
Thanks to any who can help.

I am not very good at CGI programming.

I need my CGI script to send people HTML format emails instead of standard TEXT format emails.

I have tweaked the fantastic BigNoseBird form-to-email script but it, unfortunately, doesn't allow you to send your 'Thanks' response email in HTML format. It defaults to a plain text email.

Is this easy to change?

Many thanks,
Rob

 
Could you post the code that you are having trouble with.

Perhaps the reason that HTML can not be sent with the script is not the script but the way the recepient has their mail box set up. Some mail providers (many of the HTTP free mail providers) do not allow you to recieve HTML messages.
If you are using a program such as Outlook/Express, you can customize it to allow or not allow HTML.

Hope this helps,
-Vic vic cherubini
malice365@hotmail.com
====
Knows: Perl, HTML, JavScript, C/C++, PHP, Flash, Director
====
 
I think, as soon as you have opened the mail program, add the following line:

print MAILHANDLE "Content-Type: text/html\n";

otherwise it will default to Content-Type: text/plain, so you'll just get the code showing.

Bear in mind that not everyone has html turned on in their programs as Vic says, so some people will get the html code printed out anyway.

Matt.
 
As mathew suggested, just include the Content-type line. Most recent mail clients will understand.

#!/usr/local/bin/perl
$mailprog = '/usr/lib/sendmail';
$hdr = 'Mail a gif';
$recipient = 'some.sap@nowhere.com';
$command = "$mailprog -f $hdr $recipient";
$date = `date`;

open (MAIL, "|$command") || die "Can't open $mailprog!\n";
print MAIL "From: Mr. Saps Boss\n";
print MAIL "Reply-To: \n";
print MAIL "Subject: Mail a gif in some embedded HTML\n";
print MAIL "[red]Content-Type: text/html charset=iso-8859-1[/red]\n";
print MAIL "Precedence: bulk\n\n";
print MAIL &quot;<html><body><IMG SRC=\&quot; <h1>testing html</h1></body></html>&quot;;
# Send mail to Recipient
close MAIL;
print &quot;complete\n&quot;;
exit;


keep the rudder amid ship and beware the odd typo
 
Many thanks to all the helpful responses. I relish working through them and solving my puzzle!

Again, many thanks to all,
Rob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top