Solved

SENDMAIL: Adding a "!  " to my email ?!????!?

Posted on 2006-06-13
7
869 Views
Last Modified: 2008-03-04
I'm sending an email using sendmail, and it mysteriously and randomly seems to place an exclamation mark and then a space or two ("! ") in the link URL, link, or doesn't end the a href tag where it should (will end at the end of the message sometimes). Here is the code i am using, any ideas what could be causing this??

Thanks

__________________________________________________

$r=time . '.' . $$  ;

my @mailnames=split(/ *, */,$email) ;
foreach(@mailnames) {

$link = CGI::escapeHTML($link);

#INSERT INTO DATABASE

$link = CGI::unescapeHTML($link);

$emaillink = "http://www.server.com/test.html?id=$r";
$emaillinklow = "http://www.server.com/test.html?id=$r&highspeed=no";

my $message;

$message = "<html><head><title>test</title></head><style type=\"text/css\">body, td, input, select, textarea { font-size: 13px; font-family: Trebuchet MS,  Verdana, Arial, Sans-Serif; }</style><body bgcolor=#FFFFFF marginwidth=0 marginheight=0 leftmargin=0 topmargin=0><table border=0 cellpadding=0 width=600 cellspacing=0><tr><td valign=top align=left><img src=\"http://www.server.com/images/$background.jpg\"></td></tr><tr><td valign=top align=left><table border=0 cellpadding=3 cellspacing=3><tr><td align=left valign=top>$newemailcontent<br><br><a href=\"$emaillink\"><b>$link</b></a><br><a href=\"$emaillinklow\"><b>$link - For Dial-up</b></a><br><br>$newsignature</body></html>";

open(SENDMAIL, "|$sendmail -t") || die "Unable to open sendmail";

print SENDMAIL "to: $_\n";
print SENDMAIL "from: $fromname <$fromemail>\n";
print SENDMAIL "Reply-to: $fromname <$fromemail>\n";
print SENDMAIL "Return-Path: $fromemail\n";
print SENDMAIL "MIME-Version: 1.0\n";
print SENDMAIL "subject: $subject\n";
print SENDMAIL "Content-Type: text/html; charset=us-ascii\n\n";

print SENDMAIL $message;

print SENDMAIL "\n\n";

close(SENDMAIL);

}
0
Comment
Question by:jmingo
  • 2
  • 2
  • 2
7 Comments
 
LVL 8

Expert Comment

by:Perl_Diver
ID: 16896771
looks like the same question you posted before. Close your other threads if that's the case, if not what is new abiut the problem? Nobody really answered before because this does not appear to have anything to do with perl. There is no reason I can think of why perl would insert random-ish characters.
0
 
LVL 8

Expert Comment

by:Perl_Diver
ID: 16896784
You might also attract more attention if the answer were worth 500 points.
0
 

Author Comment

by:jmingo
ID: 16896896
could peoples email clients/systems possibly be doing something to it do you suppose?
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
LVL 25

Accepted Solution

by:
clockwatcher earned 75 total points
ID: 16899830
Try throwing in some CRLFs ("\n") in there somewhere.  The SMTP RFC limits line length to 998 characters and some mail systems force that by throwing in an exclamation point followed by a CRLF.  It's a common problem with Microsoft's ASP.Net System.Web.Mail.  Maybe that's what you're running into.  It shouldn't be in the sample that you posted, but maybe you've hit a mail system which has an even shorter line length set.  RFC 2822 recommends line lengths of under 78 characters.

http://www.faqs.org/rfcs/rfc2822.html --

2.1.1. Line Length Limits

   There are two limits that this standard places on the number of
   characters in a line. Each line of characters MUST be no more than
   998 characters, and SHOULD be no more than 78 characters, excluding
   the CRLF.

   The 998 character limit is due to limitations in many implementations
   which send, receive, or store Internet Message Format messages that
   simply cannot handle more than 998 characters on a line. Receiving
   implementations would do well to handle an arbitrarily large number
   of characters in a line for robustness sake. However, there are so
   many implementations which (in compliance with the transport
   requirements of [RFC2821]) do not accept messages containing more
   than 1000 character including the CR and LF per line, it is important
   for implementations not to create such messages.

   The more conservative 78 character recommendation is to accommodate
   the many implementations of user interfaces that display these
   messages which may truncate, or disastrously wrap, the display of
   more than 78 characters per line, in spite of the fact that such
   implementations are non-conformant to the intent of this
   specification (and that of [RFC2821] if they actually cause
   information to be lost). Again, even though this limitation is put on
   messages, it is encumbant upon implementations which display messages

   to handle an arbitrarily large number of characters in a line
   (certainly at least up to the 998 character limit) for the sake of
   robustness.

0
 
LVL 25

Expert Comment

by:clockwatcher
ID: 16899837
0
 

Author Comment

by:jmingo
ID: 16902151
clockwatcher: i think that might be it.... thanks a lot!! i will fix that.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question