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
Related
I want to upload a PDF file but can't seem to serialize it correctly. Because of specific requirements I cannot use the FormDataAPI nor an HTML form.
I'm manually creating the multipart/form-data body like so.
------WebKitFormBoundaryFb3Biw9LyOW5jlUQ
Content-Disposition: form-data; name="username"
bill
------WebKitFormBoundaryFb3Biw9LyOW5jlUQ
Content-Disposition: form-data; name="file"; filename="test.pdf"
Content-Type: application/pdf
[object ArrayBuffer]
------WebKitFormBoundaryFb3Biw9LyOW5jlUQ--`
and sending the request via xhr.send(body) where body is my built up string. Is this even possible?
When I've tested using the FormDataAPI I can see the file as a nice big (encoded?) blob in the Chrome network request inspector. Is FormDataAPI doing something that I cannot achieve via JS?
I am sending some emails using wp_mail() function to send some HTML formatted emails. The problem is that the emails all look like basic plain text.
I set my headers to
$headers = array('Content-Type: text/html; charset=UTF-8');
In Windows, I use Fake SMTP server to test. The Content/Type is being recognized as text/html; charset=UTF-8
The problem is that all my emails look like basic plain text. No spacing from divs, no tables, no CSS modifications, nothing. It basically takes the text from the HTML that I wrote and puts it inline. I also tried sending the emails to GMAIL and no luck, it looks the same.
I ran out of options with testing this. What should I change?
Have you enabled HTML Headers in functions.php
add_filter( 'wp_mail', function( $params ) {
$params['headers'] = 'Content-type: text/html';
return $params;
} );
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.
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?
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