
{"id":2339,"date":"2017-02-27T17:06:37","date_gmt":"2017-02-27T22:06:37","guid":{"rendered":"http:\/\/www.ikriv.com\/blog\/?p=2339"},"modified":"2017-02-27T17:06:37","modified_gmt":"2017-02-27T22:06:37","slug":"silent-conversions-are-evil","status":"publish","type":"post","link":"https:\/\/ikriv.com\/blog\/?p=2339","title":{"rendered":"Silent conversions are evil"},"content":{"rendered":"<p><a href=\"https:\/\/sendgrid.com\/docs\/Classroom\/Build\/Format_Content\/plain_text_emails_converted_to_html.html\">SendGrid e-mail server silently converts plain text e-mails to HTML<\/a>,\u00a0losing line breaks in the process. They have some reasoning on why this is a good idea, but I do believe most silent conversions are evil, since they violate the rule of least astonishment.<\/p>\n<p>I have added a plugin to WordPress that sends e-mail notifications to a commentator when their coment is answered (this should have been a standard feature, but that&#8217;s another matter). It <em>almost<\/em> worked: the notifications did arrive, but all squished in one line. So, if the original message was<\/p>\n<p>Line One<br \/>\nLine Two<\/p>\n<p>it would show in the e-mail as &#8220;Line One Line Two&#8221;.<\/p>\n<p>Something along the way was losing the line breaks, and I had quite a few moving parts in the pipeline: the plugin, the WordPress, PHP, Apache, sendmail on my server, the mail client and any of the SMTP relays in between.<\/p>\n<p>I verified that this is not the plugin, since it sends a plain text e-mail only. After some digging I noticed that the converted HTML e-mail has some embedded image that refers to &#8220;Sendgrid&#8221;. I host my blog on Azure, and Sendgrid is the mail server they offer. And indeed, it turns out Sendgrid silently converts plain text e-mails to HTML, losing line breaks in the process.<\/p>\n<p>Silent conversions are evil: this is why C++ ended up having the\u00a0<em>explicit\u00a0<\/em>keyword. Silent conversions that lose information are especially\u00a0evil. Frankly, Sendgrid should not have done it, or at least should have made it an opt-in feature, rather than the default.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>SendGrid e-mail server silently converts plain text e-mails to HTML,\u00a0losing line breaks in the process. They have some reasoning on why this is a good idea, but I do believe <a href=\"https:\/\/ikriv.com\/blog\/?p=2339\" class=\"more-link\">[&hellip;]<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"Layout":"","footnotes":""},"categories":[1],"tags":[],"class_list":["entry","author-ikriv","post-2339","post","type-post","status-publish","format-standard","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/ikriv.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2339","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ikriv.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ikriv.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ikriv.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ikriv.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2339"}],"version-history":[{"count":1,"href":"https:\/\/ikriv.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2339\/revisions"}],"predecessor-version":[{"id":2340,"href":"https:\/\/ikriv.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2339\/revisions\/2340"}],"wp:attachment":[{"href":"https:\/\/ikriv.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2339"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ikriv.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2339"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ikriv.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2339"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}