HTML mail not being properly displayed in Gmail, Outlook, etc - html

I am sending mails from the command prompt as-
mail -s "$(echo -e "This is the subject\nContent-Type: text/html")" <my-email-id> < ~/Downloads/report-scripts/mail.html
The file mail.html is a perfectly written HTML file, which when viewed in browser, renders perfectly. However when sent through mail (say to Gmail), some layout issues creep in. See the following images -
Browser Image -
Mail Image -
Note the extra </td> element.
I understand that email providers don't render HTML mail as it, and add their own styles to it. Is there any way to resolve this issue?

Okay,
I have resolved the issue and I have an indication of what might be the problem, but I am not sure about it.
Using mutt instead of mail solved the issue. So the problem is linked to the mailing utility and not the HTML itself.
RCA-
I checked the original mail content. You can do that in Gmail by following the image
For mutt, the content was as follows -
From: <Some email id>
To: <Some email id>
Subject: <Some subject>
Message-ID: <20160218081616.GA6060#<machine description>>
MIME-Version: 1.0
Content-Type: text/html; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
User-Agent: Mutt/1.5.21 (2010-09-15)
and for mail, it was as follows -
Subject: <Some subject>
Content-Type: text/html
To: <some email id>
X-Mailer: mail (GNU Mailutils 2.99.97)
Message-Id: <20160215054331.4C3EA25E27#<machine-description>
Date: Mon, 15 Feb 2016 11:13:31 +0530 (IST)
From: <some email id>
I think it has something to do with the headers sent with the mail.

Related

How to send Email sending without html format

I send email in rails using mailer.It send successfully.But the way it send is not proper.It is sending in html tags like that
Sent mail to xxx (3.6ms)
Date: Mon, 09 Nov 2015 14:53:15 +0500
From: from#example.com
To: xxx
Message-ID: <56406d0b15b8e_6f03f8d3408607861097#des-0071.mail>
Subject: Password Reset
Mime-Version: 1.0
Content-Type: text/html;
charset=UTF-8
Content-Transfer-Encoding: 7bit
<html>
<body>
<p>Hello </p>
<p>Someone has requested a link to change your password. You can do this through the link below.</p>
<p>Change my password</p>
<p>If you didn't request this, please ignore this email.</p>
<p>Your password won't change until you access the link above and create a new one.</p>
</body>
</html>
File is password_reset.html.erb
In rails console, you can see the html tag actually. But in the real email you could not see those HTML tags. Try to run not using console but run actually how do you want it to call. Use mailcatchergem to see real results of the email.
In short, you can install and run like this:
gem install mailcatcher
run mailcatcher to your bash.
Go to browser: http://localhost:1080/
Then you can see like this image.
The email client will render those tags once the email is received by the user and you will not see any of them. An email template is treated very much like a View in Rails. if you take everything between <html> and </html> and save it in a file and open it in a browser, that's what the email will look like for the user.
Also you want to send an absolute path in your email link, that is a relative link you have right now and if the user clicks it outside your website (from an email client) it will not work.

SMTP dot-stuffing within MIME boundaries

I guess I ran into a dot-stuffing problem sending SMTP messages. What i basically want to do is to send a message with a text and a attachment part.
In my example I defined a multipart/mixed message like following:
Mime-version: 1.0
Content-Type: multipart/mixed; boundary="YJiPVI9C2M93dRDm"
--YJiPVI9C2M93dRDm
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline
Message
.
--YJiPVI9C2M93dRDm
Content-Type: application/gzip
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename=2015-06-22-114558.tar.gz
H4sIAFbZh1UCA+2dXW/dNhKGc72/QujVLtAmIocjSqdXbbH9AJJt0G63F0URuPZJYdT2MezjNP33
FXkcbyQxh6TmnX4AOTdpUs3D0ejlkOKXbGv4o7b7yNqPjHHM/ZNH8F87/jxz/HP8zf+M/20sO+PZ
--YJiPVI9C2M93dRDm--
If I send the SMTP massage with libcurl like described above i will get connection timeouts. The problem is the single point (after "Message"). I know that this is a escape sign in SMTP, but it should be interpreted as a "normal" point. So how to do this? Is the mime body correct? Do i need to masquerade the single point?

When sending an email with meteorjs, the base64 inline image is not displayed correctly

Current situation:
(Client side) The template:
<template name="feedback">
<h1>The Image</h1>
<img src="{{image}}" alt=""/>
</template>
(Client side) Calling the mail function:
var dataContext={
image: canvas.toDataURL('image/png')
};
var html=Blaze.toHTMLWithData(Template.feedback, dataContext);
Meteor.call('feedback', html);
(Server side):
Email.send({
to: 'xxx',
from: 'xxx',
subject: 'xxx',
html: html
});
Expected result: A nice email with an embedded image.
Actual result: I get a mail partially html, partially 'raw' text. I have no clue to why.
This is a part of what I see in the raw email:
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: quoted-printable
<h1>The Image</h1>
=20=20=20=20<img =
src=3D"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAB4AAAALKCAYAAADTWUxrAA
Any ideas?
Gmail, as well as many other clients, do not allow you to use base64 as a source in an img tag. There are ways around this though:
First and easiest might be to just keep the image on your server and put a url into the image source tag. This has the added benefit of being able to handle some tracking (some additional development required).
Second would be to use a third party mail system and send them the image and the HTML and set it up this way. This might be good for a number of reasons but it doesn't really answer your question.
Finally you can do this in an email template like you have by adding a multipart multitype boundary solution very similar to this answer:
base64 encoded images in email signatures

receive json in a iframe blackberry 5

hi i'm trying to upload a image from an iframe and is working, but cant get the response from the server, i try to set the target of the form to _blank and i get an promp to save the file instead of displaying it as html or plain txt when trying to open the saved file blackberry alerts "can display file" but if i send the file over Bluetooth and open it in mi pc it have the valid server response,i think that is the mime types that are preventing the iframe to load but i don't know if i'm correct
this are the header that the server return:
Cache-Control:no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Connection:Keep-Alive
Content-Type:application/json
Date:Fri, 24 Feb 2012 00:31:06 GMT
Expires:Thu, 19 Nov 1981 08:52:00 GMT
Keep-Alive:timeout=15, max=61
Pragma:no-cache
Server:Apache/1.3.42 (Unix) mod_jk/1.2.30 mod_gzip/1.3.26.1a mod_log_bytes/1.2 mod_bwlimited/1.4 mod_ssl/2.8.31 OpenSSL/0.9.8e-fips-rhel5
Transfer-Encoding:chunked
X-Powered-By:PHP/5.2.17
i get the header from a desktop chrome
i'm doing after hours to get this fixed but i canĀ“t figure out how to work around this any help will be appreciated thanks
update
i try the mime type stuff and i can reproduce the problem seting the json mime type to an arbitrary document whit this code
<?php header('Content-type: application/json'); ?>
and as spected i get de "culd no load" alert on blackberry, is there any way i can force it to show the json as plain text so i can later parse it?
Probably too late to help you out but maybe this will help someone else...
Essentially when you send text back to an empty iframe, the browsers are looking at the incomming data and if its not HTML they're wrapping tags around it.
If you change your header to content-type: text/html the browsers will not populate the iframe with html and you get the raw json.

HTML Mails by Google - No HTML Code

I received a promotional mail from Google AdWords. Because I liked the layout, I thought of giving a look at the HTML source of the mail. When I clicked 'Show original' from the mail options, I saw no HTML code, but a bunch of encoded text.
It was something like this:
--===============0308376380==
MIME-Version: 1.0
Content-Type: text/html; charset="utf-8"
Content-Transfer-Encoding: base64
PG1ldGEgaHR0cC1lcXVpdj0iQ29udGVudC1UeXBlIiBjb250ZW50PSJ0ZXh0L2h0bWw7Y2hhcnNl
dD11dGYtOCIgLz4gDQo8ZGl2IHN0eWxlPSJjb2xvcjojMTExOyBmb250LXNpemU6MTIuOHB4OyBm
b250LWZhbWlseTpBcmlhbCxzYW5zLXNlcmlmOyBsaW5lLWhlaWdodDoxNDAlOyBwYWRkaW5nOjAg
MzBweDsiPiANCiANCgkJPGRpdiBzdHlsZT0iYm9yZGVyLWJvdHRvbTogMXB4IHNvbGlkICM5OTk7
IG92ZXJmbG93OiBoaWRkZW47IG1hcmdpbi10b3A6IDBweDsgbWFyZ2luLWJvdHRvbTogMi40ZW07
Ij4NCjxwIHN0eWxlPSJmb250LXNpemU6MTNweDsgZmxvYXQ6cmlnaHQ7IGNvbG9yOiM2NjY7IG1h
cmdpbjowOyBmb250LXdlaWdodDpib2xkOyI+RW1haWwgMiBvZiA2PC9wPg0KPGltZyBzcmM9Imh0
dHA6Ly93d3cuZ29vZ2xlLmNvbS9hZHdvcmRzL25ld3NsZXR0ZXJzL2ltYWdlcy9sb2dvX2dvb2ds
ZS5naWYiIGFsdD0iR29vZ2xlIiBzdHlsZT0ibWFyZ2luLWJvdHRvbToxcHg7IiAvPg0KPC9kaXY+
DQogDQoJPHAgc3R5bGU9Im1hcmdpbi1ib3R0b206MWVtOyI+SGVsbG8sPC9wPiANCgk8cCBzdHls
ZT0ibWFyZ2luLWJvdHRvbToxZW07Ij5LZXl3b3JkcyBhcmUgdGhlIHNlYXJjaCB0ZXJtcyAod29y
ZHMgb3IgcGhyYXNlcykgd2hpY2ggdHJpZ2dlciB5b3VyIGFkLCBhbmQgdGhleSBhcmUgY3JpdGlj
YWwgdG8gdGhlIHN1Y2Nlc3Mgb2YgeW91ciBBZFdvcmRzIGFkdmVydGlzaW5nLiBUaGlzIGVtYWls
IGV4cGxhaW5zIGhvdyB5b3UgY2FuIGNob29zZSB0aGUgbW9zdCBlZmZlY3RpdmUga2V5d29yZHMs
IGFzc2VzcyB5b3VyIGtleXdvcmQgcGVyZm9ybWFuY2UgYW5kIGhvdyB0aGlzIGFmZmVjdHMgdGhl
IGFtb3VudCB5b3UgcGF5LjwvcD4gDQogDQoJPGgyIHN0eWxlPSJjbGVhcjpib3RoOyBjb2xvcjoj
.........
............
....
.....................
--===============0308376380==--
What's happening here? How the HTML is encoded? Is there a way to decode these stuff? Thanks!
The HTML is base64 encoded:
Content-Transfer-Encoding: base64
you can decode it using PHP:
echo base64_decode($text);
or online:
http://www.motobit.com/util/base64-decoder-encoder.asp
The encoding is base64. There should be modules to convert to and from base64 in almost all programming languages. However, if you are on linux, you can try:
base64 -d