1

I am new to Perl and I am trying to send an email using the Mail::Sender module with HTML in the body part. I am using debug => 'x.log' to analyze the mail sending process.

It looks like Perl is weirdly putting 3D after each '=' sign and 20 for each space in my HTML code (looks like URL codes for HTML). And after this no email is received at by client. What could be a problem here? (e.g. border="5" becomes border=3D"5")

I am using $sender->SendEnc($BODY); to send message and $sender->Open({to => "$userAtFaultEmail", subject => "$email_subject", ctype => "text/html", encoding => "quoted-printable"'}); to open mail connection.

cjm
  • 61,471
  • 9
  • 126
  • 175
mrig
  • 382
  • 1
  • 4
  • 21

1 Answers1

3

This is perfectly natural. In the quoted-printable-encoding, the equality sign = is the escape character, so it has to be escaped itself. After the escape character, the hex number of the character is given. Mail clients will decode it correctly. If you dislike this, you can change the encoding, e.g. to UTF-8. However, this is not that common and may produce new issues with legacy clients.

Here is the Wikipedia entry about quoted-printable. The reason for this encoding is to encode 8-bit characters, while email traditionally only transmits 7-bit ASCII.

amon
  • 57,091
  • 2
  • 89
  • 149
  • 2
    `UTF-8` would be the character set, it isn't a valid value for the `encoding` parameter. The value for that to avoid actually encoding the content would be `8bit`. – qqx Nov 26 '12 at 23:01
  • @amon okay, so I get right view in the debug log file, but the mail is not received at the client now. Am I require to change any parameter in the open command. I am trying to send a html code for table and right now it is: `$sender->Open({to => "$userEmail", subject => "$subject", ctype => "text/html", charset=>"utf-8"});` (it works when there is no html in message) – mrig Nov 26 '12 at 23:30
  • @mrig Emails must follow the [MIME](https://en.wikipedia.org/wiki/MIME) standard. As @qqx said, the encoding would be `8bit` or `binary`. This is the *transfer encoding*. How the resulting data stream is interpreted is set by the *content type*. Setting `ctype` to `text/html; charset=utf-8` should do the trick. – amon Nov 27 '12 at 00:01
  • @amon yup, it worked. The other bug was, me putting '\n' for my readability of final outgoing message instead of '\r\n'.Thanks everyone!! – mrig Nov 27 '12 at 00:41
  • @mrig That HTML is *really* bad style, and you probably want to use `≤` or `≤`, but it renders fine. Also, spaces are irrellevant in HTML. Mail clients like Thunderbird can easily send and receive such mail. You are probably making false assumptions in your code, sending bogus headers, or suffering from other mistakes stemming from your unfamiliarity with the appropriate standards. Maybe, opening a new question on this issue *and* providing the problematic code could be the wisest choice. – amon Nov 27 '12 at 13:46
  • @amon i know spaces are irrelevant and thats why its odd that mail/sender module doesnt handles that. But again as you said, problem could be in some other part of the code. I will take your suggestion to open a new question to focus on problematic code. Thanks!! – mrig Nov 27 '12 at 23:00
  • finally....there was no problem with perl script, the outlook filter or my company filer was marking the mails as spam and i realized that really late. So much of time given to that!! But thanks everyone!! – mrig Dec 03 '12 at 08:51