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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

html email not being sent as html 1

Status
Not open for further replies.

tviman

Programmer
Jul 25, 2002
2,123
US
I'm stumped on this one. I want to send an HTML formatted email to a single user. I've included all the correct header info in the correct places (I think) but all we receive is a plain text email with all the html formatting.

Here's part of the code:

Code:
#!/usr/bin/perl -w

use CGI qw(:standard);
use CGI::Carp qw(fatalsToBrowser);
use Net::SMTP;  
$smtp->mail( $email );  
$smtp->to( $MailTo ); 

# Start the mail  
$smtp->data(); 
$smtp->datasend("To: $MailTo\n"); 
$smtp->datasend("From: $email\n");  
$smtp->datasend("Subject: Request for Quotation\n\n");  
$smtp->datasend("MIME-Version: 1.0\n");
$smtp->datasend("Content-Transfer-Encoding: quoted-printable\n");
$smtp->datasend("Content-type: text/html;  charset=ISO-8859-1\n\n");
$smtp->datasend("<html><body> $table1");
$smtp->datasend("<tr><td>Company Name</td><td> $company</td></tr>");
$smtp->datasend("<tr><td>Contact</td><td> $name</td></tr>");
.
.
.
$smtp->datasend("<tr><td></table>");
$smtp->datasend("</body></html>\n");

# Send the termination string  
$smtp->dataend(); 

# Close the connection  
$smtp->quit();

and this is what we receive:

MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Content-type: text/html; charset=ISO-8859-1

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><body> <table width="50%" border="1" cellpadding="0" cellspacing="0"><tr><td>Company Name</td><td> Fred Frick Co</td></tr><tr><td>Contact</td><td> Fred Frick</td></tr>
.
.
.
</table></body></html>

I've worked all day on this trying make it work so I'm of the opinion now that there's something I'm not seeing.

The email client IS configured to read HTML email - we receive several of them every day.

I'd appreciate any help from you kind folks.

Thanks

Patrick

There's always a better way. The fun is trying to find it!
 
Hi,

Try taking away one of the newlines \n from the Subject ...

Why would that work? not sure really? but I've been round the same loop before!!

Hope this helps
SP
 
sorry to be a little clearer:

change
$smtp->datasend("Subject: Request for Quotation\n\n");
to
$smtp->datasend("Subject: Request for Quotation\n");

it appears that you need to place your header information on the next line after subject ... same also applies for sendmail HTML formatted emails.
 
That was the ticket!!! Thanks so much for your help. I'd looked at every script I could find but apparantly I wasn't looking close enough. Would'a thunk that a newline would have made the difference?

Thanks again!

There's always a better way. The fun is trying to find it!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top