Passing quotes to html email with Perl::Sendmail

35 views
Skip to first unread message

Nevil...@gmail.com

unread,
Jul 29, 2006, 2:20:22 PM7/29/06
to Perl Mail::Sendmail
Hi, I am building a page that should email out some html. It is working
to yahoo mail, but not working to other smtp servers, most notable
exchange servers. The problem is that when $html is sent the "
character gets mangled. It looks like " is escaping something somewhere
beacuse when I have $html containing <img src="http://some/where.jpg">
the page source that comes back from outlook web front end shows this:
<img src=ttp://some/where.jpg">

Any idea? Here is the code I am using:
#!/usr/local/bin/perl
use strict;
use MIME::QuotedPrint;
use HTML::Entities;
use Mail::Sendmail;

my $boundary = "====" . time() . "====";


my %mail = (
from => 'x...@xxx.com',
to => 'x...@xxx.com',
subject => 'Test HTML mail',
'content-type' => "multipart/alternative;
boundary=\"$boundary\""
);


$boundary = '--'.$boundary;

$mail{body} = <<END_OF_BODY;


$boundary
Content-Type: text/html; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<html>
Please visit our site <a href="http://cyberciti.biz/";>online</a><hr>
<img src="http://boardingbandit.com/printedatbanner.jpg">
</html>
$boundary--
END_OF_BODY

sendmail(%mail) || print "Error: $Mail::Sendmail::error\n";

Nevil...@gmail.com

unread,
Jul 29, 2006, 3:54:18 PM7/29/06
to Perl Mail::Sendmail
I figured it out. Exchange servers like 8 bit encoding not
quoted-printable. I changed the line to read Content-Transfer-Encoding:
8 bit. It now works.

mi

unread,
Aug 13, 2006, 6:41:24 AM8/13/06
to Perl Mail::Sendmail
> Content-Type: text/html; charset="iso-8859-1"
> Content-Transfer-Encoding: quoted-printable

You are specifying quoted-printable encoding, but you don't seem to be
sending the HTML encoded at all.

Either use

Content-Transfer-Encoding: 8bit

(as you discovered)

Or encode your HTML first, instead of writing it straight into the
body:

$html = q{ your html code };
$html = encode_qp($html);

This is better, because in case your HTML has lines exceeding the
maximum length for email messages, the encoding will automatically take
care of splitting such lines.

Reply all
Reply to author
Forward
0 new messages