I have a bunch of emails which are written using MJML. The output HTML seems to be correct.
As an email sender, I'm using AWS SES. But after sending, all my CSS styles in an email are broken. To send an email, I'm using method ses.sendEmail.
I have tried to use CSS injected in HTML head and inline styles. Does not work.
What could be the problem with it? Thanks!
First, check your HTML. Send it through either of these free sites: https://www.putsmail.com (requires a free Litmus account; they're an established and reputable Email Service Provider, ESP) or https://useparcel.com/ (an editor for email HTML; put your HTML in the editor and use their free send feature). With putsmail, don't accept their offer to inline your CSS for you--that'll change your HTML.
When each email arrives, compare the HTML received to what you sent. Diff tools are helpful.
I just sent a 1300+ line HTML file through each of those. For both, every character arrived unchanged, except for blank lines after the </html>. That's okay with me!
Compare the rendering to what you see in one of the MJML rendering tools (maybe https://mjml.io/try-it-live or the MJML desktop app https://mjmlio.github.io/mjml-app/). Do not depend on the rendering in any one email client as fully representative of the HTML; most of them have quirks. (I'm lookin' at you, all Outlooks except Apple's! And GMail. And Yahoo!. More at https://caniemail.com/ .)
I did a little research on AWS ses.sendmail. There's important advice and information at both of these.
https://docs.aws.amazon.com/ses/latest/DeveloperGuide/send-email-sendmail.html
https://docs.aws.amazon.com/ses/latest/APIReference/API_SendEmail.html
I found an SO ticket from a little less than a year ago that could be relevant.
AWS Amplify SES sendmail AccessDenied
Recommend you review all that. Maybe something there will improve your experience.
Last, some standard advice from the world of email HTML. If you get sendmail working, perhaps it doesn't apply.
Send your HTML using an ESP that doesn't change your HTML. For people sending lots of email, there are lots of good reasons for using an ESP. Many provide valuable services. By the same token, some ESPs change the HTML before sending; lots of us avoid them.
I hope you get it figured out. Email HTML is, as you're experiencing, anything but easy.
Related
When you buy a flight and receive a confirmation email, GMail recognizes it's a flight and adds departure/return tabs at the top of the message.
Using GMail API, I would like to use that information to get all flights from my inbox. Is this possible?
Content that is outside the message body of an email is not accessible from the GMail API. So you won't be able to access the info in any auto-generated tabs.
However, GMail may have auto-labeled the messages as "Travel". If that's the case then you can leverage the GMail API to filter messages using the "Travel" label.
You'll then have to parse the email message for the desired information.
Writing a custom parser can be difficult. However, if the message is annotated so that it conforms to specifications outlined by Google and Schema.org, parsing flight information will be considerably easier. One can assume that flight confirmation messages that trigger the auto-generation of those tabs have flight/reservation specific mark-up embedded within them (but you should probably verify that the email contains said mark-up all the same).
The following links discuss how vendors should embed these special mark-up into their messages:
https://developers.google.com/gmail/markup/getting-started
https://developers.google.com/gmail/markup/reference/flight-reservation#basic_flight_confirmation
You should be able to use those docs to build a custom parser that can detect and parse the required mark-up schema or better yet leverage an open-source library to do so.
Sometimes the rendered display of an HTML email body is incorrect. Eg:
OC gmail is rendered correct
Mobile app gmail is rendered correct
Mobile web gmail is rendered incorrect
This problem occurred only on mobile web gmail.
HTML body has a <table> tag. In the incorrect case, this table tag is broken with part of <div> tag.
I tried several times in mobile web gmail. The first email displayed correctly
but the second email displayed incorrectly.
My question is: why this happen? How do I fix it?
It's been a while since this question was asked, but I ran across the same problem myself now in 2022.
First of course I looked for the error on our end and rebuilt html/css. However, I could not find the error, it seemed to happen completely randomly.
A completely identical email sometimes looked perfectly fine, sometimes it was rendered completely broken (this can also be seen by looking at the HTML code: clean code turned into a completely chopped up array of HTML code that was definitely not ours (especially early terminated HTML tables, heaps of "empty" snippets, etc).
Then, by chance, I noticed that this phenomenon does NOT occur if I permanently delete similar emails that are ALREADY in the trash (sic!).
I have been able to narrow down the problem even further: apparently GMail bundles messages, from the same domain and with the same subject line, even if they are in the trash (however, you do NOT see this directly in the inbox, but only when you are on the (broken) email in question and refresh by dragging down (mobile) - all of a sudden, all the trash messages are additionally visible at the top of this message).
I was able to fix the problem by always writing value into the subject line that does not match any other email. This avoids the incorrect bundling and the mails look flawless again.
Cost me a lot of nerves and half a day's work - maybe I can save this for someone with my contribution.
I am working on a web application which allows users to share stuff on a web-page by clicking on an 'email to friend' link; similar to what extole is doing here
http://www.american-giant.com/mens-heavyweight-full-zip-hooded-sweatshirt-product.html
on this page if you click on the email icon near "REFER & GET $15", you will see a pop-up where you can enter your own email and a friends email and can edit the subject of the email. When you click send the data is sent to the backend as json. They are using a plain simple url to do this i.e. http://refer.american-giant.com/v2/share.
The problem for me is that somehow spammers got hold of my url (can't mention here) and now they are using it to spam others by using some sort of a script. What I did is I placed a check in the backend api to block an ip if more than 5 share requests originate from it, but it seems that the spammers have a lots of ips (more than 30,000 from what I counted in my logs) so they are still able to send lots of email. One possible solution is to use a captcha to thwart the spamming script. But I am curious that how extole is doing it. They aren't using any captchas; and they are famous too, so it is unlikely that spammers don't know about their publicly accessible api. Can any one shed some light on this?
Note:
1. I am using a third party email service to send the emails.
2. Users are not required to sign in as this defeats the purpose of sharing on a simple website
3. Users can edit the subject and body, thus these are sent to the api call and this is what allows the spammers to abuse the api with their own stuff.
I need to send emails form a script where the SMTP I want to send by varies per message. Using mailx, one may specify the SMTP server, TLS options, username, and password on the command line. However, I need to send embedded HTML emails (not as attachment), and mailx does not support that, according to various posts I've found and time spent pulling my hair out trying to get it to work. On the other hand, with sendmail I can send embedded HTML, but it seems the SMTP server options have to be in a config file, and I don't know how to override them from the command line. So how do I send embedded HTML while specifying custom SMTP options?
I gather you're looking for a low-level solution, but this is so straightforward in Python that I think it's worth exploring. There are several examples of literally exactly what you're trying to do right here in the documentation.
I also answered a similar question here.
Even if you're unfamiliar with Python, those docs pages pretty much spell out the whole program for you.
I am trying to build a service where anybody can send an image file from an email address/client and process it. Think about the service a bit like Flickr showing the image in a dashboard that comes via emails
From a usability standpoint this mechanic offers great deal of advantage but I want to understand the security consequences of such an action.Some concerns are:
I need to validate all these files as images
People can probably send a file with an exploit/code that can likely
be a problem. But in my case I am mostly going to do a file open and
save and let the browser show the image
Am I taking the right approach here? Are there serious consequences that I should be of?
Things you should do and take into consideration.
Make sure your mail server is configured for virus scanning, keep it up to date. That'll be the first line of defense.
When the email comes in, attempt to process the image in a known rock solid library.
Be aware that many emails contain multiple images, some of which may have nothing at all to do with the one they are sending. For example, our company emails all include our logo at the bottom. I'm not exactly sure what the solution is here, but you'll want to take it into consideration.
Different email clients handle image attachments, well, differently. Sometimes it's as a normal attachment, sometimes it's embedded in the body. Even within the same client an image might be handled differently depending on if they sent the email as plaint text with attachments or HTML mail.
People will test your system. They'll send .js files, they'll send images whose headers are jacked in order to overflow your image processing library...
Consider enforcing certain email restrictions such as SPF checks.
Be prepared to receive images that are absolutely huge. Today's cameras take very large photos and a lot of people don't know what crop or resize means. You might consider setting a cap of 15MB or larger per email coming into your server. Then, in combination with #2 above, auto resizing images down to something a bit more acceptable.
Determine the mechanism you actually want to use to notify the user of any issues. Bear in mind that this mechanism is subject to abuse. For example, consider a spam message sent to your machine with reply-to headers going to a victim.
If you are using .net, see this for a possible way to confirm a file is an image: How can I determine if a file is an image file in .NET?
I'm not saying this is 100% secure (can you ever be 100% secure?) but here is something that you can try:
Lets say that you have an alias on your postfix (or whatever mail system) that redirects incoming emails to a php/bash/python script for further processing.
The first thing I would do is use an image manipulation library (say imagemagick) and convert all incoming files to a .png format or whatever, and only proceed further with your logic if the conversion is successful.
This way, if someone sends you any malicious attachments (php exploit, jar's, swf's, anything) the conversion will fail, and hence it will be disregarded by your system.
Edit: ImageMagick has the "identify" command which does exactly what you want.
Emails could be easily spoofed as well, which means I can send an email from an email address which doesn't belong to me.
This might help also: Secure way to upload image in PHP ...