smtp sends headers as content - google-app-engine

I'm using remote smtp server(from my host company) and send
email from local computer.(google app development server)
But instead of getting nice emails
i get emails that contain headers as if it ware content of email
What can do to change it?

My guess is that you have a newline (\r\n or Carriage Return -Line Feed) in your subject. And, your mailing program doesn't strip newlines in the subject.
If you put a newline in the subject, and your app doesn't remove it, you just moved all following headers down to the body.

Send the email according to the SMTP RFC: https://www.rfc-editor.org/rfc/rfc5321
Getting the headers in the content sounds like you sent them twice or did separate the headers from the content in a way your mail client does not understand.

Check you don't have something wrapping what you send in another layer of email.
Perhaps look at the current (real/outer) headers to see if that gives any clues.

Can you show us your code, please? You don't say which App Engine runtime you're using; I'll assume Python. The App Engine mail API doesn't let you directly set message headers. There's a list of attributes you can set here.

Related

Sending threaded email from Google App Engine

I've got an app that's sending email from AppEngine, but each email looks like it's a unique message. Instead I want related emails to be threaded in my email client. Is there a specific header/format I need to use?
These emails are not necessarily in response to another email, so I don't have a Message-ID to plug into References. I've tried using a natural key in References and In-Reply-To to no avail.
I was able to thread a list of emails just by using the In-Reply-To header with your format <msg-identifier#host>.
Supposedly, msg-identifier is the identifier to the message you're replying to, but as you're not replying to any message but sending all of them out of thin air, creating a new ID and using it in all the emails you send will also do the trick.
I got this working by using both References and In-Reply-To with the format <identifier#systemname>. Maybe it'll work with less; I made several changes at once. If someone chimes in with that kind of detail I'll happily accept their answer instead of mine.

How to request read receipt with Google App Engine

I have a GAE application which sends out email to my domain users in a Google Apps for Business environment. I am using JavaMail as described in this article. Unfortunately I can't seem to find a way to ask for a read receipt. I looked at Message methods but nothing seems to suggest that it is possible. Thanks a lot.
If you're interested in knowing if a mail bounced, then use bounce notification https://developers.google.com/appengine/docs/java/mail/bounce
For read receipts:
As far as I'm aware, you need to roll your own read receipt functionality. For example: Include an image(with a unique url) in the mail you send out. When the recipient opens the mail, the image is retrieved and you can determine whether the mail has been read. This has it's downsides; if they don't have images enabled, then you won't receive the notification.
You need to set the appropriate headers on your message, as described in Message Disposition Notification - RFC 3798. Not all mailers will honor MDNs, so you might find the tracking pixel useful as well. But then some mailers won't display remote images, so in the end there's no guaranteed way of getting notified when a message is read.

How to get important flag from Java Mail client

Is there a way to get whether a mail is marked as important or not from Java Mail API.? I'm using a Gmail account to connect. Thanks in advance.
Different mailers use different ways to indicate that a message is "important". Some use an X-Priority header. Others use an Importance header. I don't know offhand what Gmail uses, but look at the raw headers of a message and you should be able to figure it out. Then use the JavaMail getHeader method to access that header.

How to read e-mails in a local directory using Java?

I would like to create a java program that would get only the body/message of the mail, the mails are in .eml format and the mails are placed locally in my machine. The problem is when I try to look for ways to do this I'm still lead to use the Folder class which requires an active mail server. Now, my question is, is there any way I can extract the message part of an e-mail using the Javamail API without the need to connect to a server? Because doing the extraction of the message part of an e-mail without including its headers is nearly impossible with filestream.
Thanks for the help.
Cheers!
You can use a "local store provider" for JavaMail, but perhaps the simplest approach for you is to just use the MimeMessage that takes an InputStream. Give it a (buffered) FileInputStream and it will parse the message for you.

saving appengine mail from spam filters

One of my clients uses Trend Micro InterScan Messaging Security to protect their internal mail services.
Suddenly InterScan decided to filter out all messages coming from Google App Engine.
Unfortunately they haven't been able to whitelist the sender address as each e-mail gets a different one. For example, *3ckihSOVMMHlZHSL.JSMMHlZHSL.JS*#apphosting.bounces.google.com, with everything before the # being variable.
Update I'm including this screenshot of how Interscan sees the incoming e-mail. Notice that all senders are different:
If I look into the e-mail headers, the apphosting domain appears inside the Return-Path field:
Return-Path: <36kSiSwYIBh0883XL3E7.5EH883XL3E7.5E#apphosting.bounces.google.com>
The "From" field looks ok. It says what I set it to say, but the spam filter only looks at the Return-Path.
My client sysadmin doesn't want to whitelist the whole apphosting domain, as it wouldn't be only whitelisting my application.
How could I bypass this e-mail filters if I can't get an unique sender?
Thanks,
You can't change the return-path header of mail sent by App Engine. The way I see it, you have two options:
Whitelist everything from App Engine. Spam from App Engine is not a big problem, because it's expensive to send in the huge numbers spammers need, and we're constantly monitoring for spamming and shutting spammers down.
Whitelist based on the X-Google-Appengine-App-Id header, which will be set to the app ID of your app.
I am not well versed in spam filters, but it seems to me that if it can only whitelist based on one field, it is pretty lame. Unfortunately that does not help you. If this is an important client, and they absolutely refuse to budge, I see two possible paths forward:
Do some research into interscan to see if you can give the client some pointers (tactfully) on how to configure it to whitelist in such a way that your mail can get through, but only your mail.
Maintain a server outside app engine specifically for the purpose of sending emails. You can build a super simple web app that just sends out emails, and call it from within your app engine app.

Resources