Is there any reason why a Content-Transfer-Encoding
of quoted-printable
would be screwing up a link, when sent from a SMTP server?
Example:
After setting the mail from
, rcpt to
and entering data
mode, send this (emails removed):
From: Me <[email protected]>
To: You <[email protected]>
Subject: Email Test
Mime-Version: 1.0;
Content-Type: text/html; charset="UTF-8";
Content-Transfer-Encoding: quoted-printable;
<html>
<body>
<a href="https://www.google.com/">Google</a>
</body>
</html>
Then the email source is somehow getting screwed up and the a tag is changed to <a href=3D"ttps://www.google.com/"">Google</a>
(missing h
from https
).
If I change the Encoding to be 7bit
then everything works fine.
For anyone that happens to come across this post - the issue was a simple one but not one that was immediately obvious to begin with.
When using quoted-printable
you have to make sure you're passing properly encoded data. I was not. I was passing normal HTML through, thinking that was ok.
So in my example, the <a>
tag would have to be encoded to <a href=3D"https://www.google.com/">Google</a>
then it works.
I was trying to implement this using Go, so below is a function that will implement this functionality...
// Returns a properly quoted-printable string
func toQuotedPrintable(s *string) error {
var b bytes.Buffer
w := quotedprintable.NewWriter(&b)
_, err := w.Write([]byte(*s))
if err != nil {
log.Println("Error while decoding to quoted-printable", err)
return err
}
err = w.Close()
if err != nil {
log.Println("Error while decoding to quoted-printable", err)
return err
}
*s = b.String()
return nil
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With