View Full Version : SendMail/RFC Content/Type
compbrat75
09-14-2004, 03:11 PM
Hello all,
I hope this is the right place to post this question.
I have a PERL script that sends out a newsletter using a multipart/mixed format. It sends both a text and an html version of the email and lets the email client decide which to display. This works great for 75% of the email recipients; however, I get a complaint often about blank emails showing up especially with Yahoo mail accounts. The HTML emails are mainly text with one or two graphics.
Has anyone had problems with newsletter recipients that have Yahoo email accounts? Do they need a different content/type setting? Is there anything special about boundaries with Yahoo?
Any insight would be greatly appreciated.
Thanks,
~Maria
compbrat75
09-28-2004, 02:46 PM
Answered my own questions after much trial and error, but maybe this answer will help others . . .
First off, I errored in my previous message. My content type is multipart/alternative. Which is the contenty type that allows for sending of differently formatted messages in the same email.
Apparently, I had a space at the end of my boundaries that separated the alternative messages. That space was ignored by most email client programs; however, Yahoo!Mail was being most particular and refused to display any part of the body of the message due to this syntax error.
I have a great PERL script for sending email and believe in the free exchange of ideas and code, so here is my code. It probably isn't as sophisticated as others, but it works well for my needs.
#!/usr/bin/perl -w
# sendmail script for PERL
# by Maria Meyers on January 22, 2002
my $textmess = "
Dear Message Recipient: \n\n
I am sending you some sort of text message here in this email.\r
I hope that you like this ASCII text message.\n";
my $htmlmess = "
<body bgcolor='#FFFFFF'>
<p>
Dear Message Recipient:
</p>
<p>
I am sending you some sort of HTML formatted message here in this email.
<br>
I hope that you like this HTML formatted message.
</p>
</body>";
open(FILE,"< emails.txt") || die;
while (<FILE>) {
$email=$_;
use CGI;
open(MAIL, "|/bin/sendmail -t");
print MAIL "To: $email \n";
print MAIL "Bcc: me\@my\.com\n";
print MAIL "From: myfromaddress\@my\.com \n";
print MAIL "Subject: Alternatives Types in One Email \n";
print MAIL "MIME-version: 1\.0 \n";
print MAIL "Return-Path: me\@my\.com \n";
print MAIL "Content-Transfer-Encoding: 7bit \n";
print MAIL "Content-Base: http://my\.com \n";
print MAIL "Content-Disposition: inline \n";
print MAIL "Content-Type: multipart/alternative; boundary=\"xxxboundaryxxx\" \r\n";
print MAIL "--xxxboundaryxxx\r\n";
print MAIL "Content-Type: text/plain \r\n\n";
print MAIL "$textmess \r\n\n";
print MAIL "--xxxboundaryxxx\r\n";
print MAIL "Content-Type: text/html \r\n\n";
print MAIL "$htmlmess \r\n\n";
print MAIL "--xxxboundaryxxx-- \n";
close(MAIL);
}
close(FILE);
Hope this helps someone. It was a blessing when I finally figured it all out!
Take Care,
~compbrat75
Powered by vBulletin™ Version 4.0.3 Copyright © 2010 vBulletin Solutions, Inc. All rights reserved.