In our application we are implementing the Send As feature from Gmail client.
https://support.google.com/mail/answer/22370
We are setting the From, To and Reply To headers accordingly to the settings that are set for the external account. Are there other headers that should be set when sending message in behave of external account? For example when we have set another SMTP server for the current external account.
Well, according to User Messages API Document, these are all the headers you need to add:
Users.messages: send
Sends the specified message to the recipients in the To, Cc, and Bcc
headers. Try it now or see an example.
This method supports an /upload URI and accepts uploaded media with
the following characteristics:
Maximum file size: 35MB Accepted Media MIME types: message/rfc822
Be sure to be authorized first, and apply best practices on sending to external accounts.
Related
I'm using a 32-bit microcontroller (program code written in C) with very limited flash space that is communicating with a cellular module. I have an Azure account setup with an IoT Hub and I would like to send some device-to-cloud messages to my IoT Hub. I have tested and confirmed both HTTP and HTTPS communication to other servers. However, I can't find anywhere that specifies what the required HTTP headers are for sending a device-to-cloud message. Can anyone provide a description of the required HTTP message format (the HTTP start line, required HTTP headers and the HTTP header values)?
I found the Azure SDK for C, but even with all the optimization options turned on it takes up too much codespace for my microcontroller. I've tried following the code in the SDK for how the HTTP message is built, but I seem to be missing some pieces. I only have two or three device-to-cloud messages that I am sending, so I assume that if I know what the headers are it won't take much code to generate the device-to-cloud messages.
The cellular module I have is handling the X.509 certificates for mutual TLS authentication. Assume that is working. For this question I'm only concerned with finding the required HTTP message formatting for a Azure IoT device-to-cloud message.
EDIT:
Following a suggestion from a comment, I was eventually led to this page:
https://learn.microsoft.com/en-us/rest/api/iothub/device/senddeviceevent
Using the suggested HTTP POST (with my device specifics replaced), I am now getting a 401 error (IotHubUnauthorizedAccess). I thought I understood how the authentication was supposed to work, but I guess I was wrong.
My IoT device has a symmetric key. I thought I was supposed to include a header formatted as:
Authorization:SharedAccessKey=<my_primary_key>
but that doesn't work. My HTTP body is simply:
{"deviceID":<my_IoT_Device_ID>}
Where am I supposed to include the symmetric key information, and what is its format?
After some trial and error, we found out it's much easier than we thought. If you are using X.509 certificates for client authentication, you don't need to include anything in the HTTP message content to specify your authentication. The minimum required for an Azure device-to-cloud message using X.509 certificates for authentication is:
POST /devices/<id>/messages/events?api-version=2018-06-30 HTTP/1.1
Host:<fully-qualified-iothubname>.azure-devices.net
Content-Length:<number-of-bytes-in-the-JSON-body>
{"deviceID":"<id>",<your-JSON-formatted-custom-d2c-message-data>}
where <id> is the device ID as listed on the Azure IoT Hub and <fully-qualified-iothubname> is the IoT Hub name. I believe Azure supports chunked encoding if you want to do that instead of using the Content-Length header.
I'm trying to send an email with a header via GAE Mail API. I set a header:
message.setHeader("X-Priority", "1");
But AppEngine ignores it. And when I receive an email it doesn't contain a priority header.
Does anybody know how can I set the priority header for outgoing emails?
The Google App Engine Mail API only supports the specific headers listed in the documentation, currently:
In-Reply-To
List-Id
List-Unsubscribe
On-Behalf-Of
References
Resent-Date
Resent-From
Resent-To
I am using GMail API to create drafts and redirect user to be able to review and send.
However the Reply-To header seems to be ignored by GMail API
My header is:
X-Sender: email#from.domain
X-Receiver: email#to.domain
MIME-Version: 1.0
From: email#from.domain
To: email#to.domain
Reply-To: someotheremail#domain.tld
Subject: subject
Content-Type: text/html;charset=utf
Email Body
But when the recipient of the email hits reply button, the From address is used to reply instead of Reply-To.Tried to send the email from browser as well as fully automated via API too.
Any ideas ?
Ah got it. I must supply Return-Path: as well.
How do I prevent the '....com via 2uix4h7xygsz66weerlq.apphosting.bounces.google.com' from showing up in the header when sending email from AppEngine? I'm sending to myself yet it still shows.
I found this page which says
https://support.google.com/mail/answer/1311182?hl=en-GB&ctx=mail&authuser=1#
I'm a sender and I don't want my recipients to see the "via" link. What can I do?
Gmail checks whether emails are correctly authenticated. If your messages are sent by a bulk mailing vendor or by third-party affiliates, please publish an SPF record that includes the IPs of the vendor or affiliates which send your messages and sign your messages with a DKIM signature that is associated with your domain.
Yet looking at the headers, it shows that SPF and DKIM are already set and passed!
Return-Path: <3OIblUgoJBXcWVif-mZXjibhVdg.XjhXcgjZjidsYZqx.Xjh#2uix4h7xygsz66weerlq.apphosting.bounces.google.com>
Received-SPF: pass (google.com: domain of 3OIblUgoJBXcWVif-mZXjibhVdg.XjhXcgjZjidsYZqx.Xjh#2uix4h7xygsz66weerlq.apphosting.bounces.google.com designates 209.85.212.72 as permitted sender) client-ip=209.85.212.72;
Authentication-Results: mx.google.com;
spf=pass (google.com: domain of 3OIblUgoJBXcWVif-mZXjibhVdg.XjhXcgjZjidsYZqx.Xjh#2uix4h7xygsz66weerlq.apphosting.bounces.google.com designates 209.85.212.72 as permitted sender) smtp.mail=3OIblUgoJBXcWVif-mZXjibhVdg.XjhXcgjZjidsYZqx.Xjh#2uix4h7xygsz66weerlq.apphosting.bounces.google.com
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20130820;
h=mime-version:reply-to:message-id:date:subject:from:to:content-type;
bh=chRsCD+FjUjL41bfEeXlAef5gWxlIYtGdgQGKtsk5nQ=;
b=g+3WZtFRy1F6d5cRX94eRcKaNk4yg8M1OS/qUDV9ju8El7XIxE5KGsR+6Jo5rOB5ZX
g3U3Gb9KRTOm3FQ7d7X3mVbZUauuZOYzmpijJ65R0Qnc5U0sljIB5IYmKropnxJHIeyi
DOuaL6FFMfrDclpWf1E9o8eXclkAxTdllRTQxjWrc91vucH89dMfs8jCF/KmWUFMECuX
Z69zmxKEnNn0FXZXP5i0FodxfZlb6qn7OSKeE4MVpehBIA7l0bsVv8pLOWQmBWSrQHqr
fD9dlC0r3+hYmYR8lxrR+7mtikt+hOnD3SIV7Vh0+MtZH3rOqKT5uJo262SGbD66Ckgf
yZ3A==
The code is rather mild
Message message = prepareMessage();
Transport.send(message);
Domains that want to reliably send emails should have DKIM and SPF set in their DNS configuration. This is needed to that you email does not get marked as spam.
If you send from #gmail.com, than Google sets this. But if you send mail from you custom domain, then you need to set this on your own.
In your case it seems that you send from custom domain, so google adds a "via" header along with it's own DKIM/SPF records so that this mail has better spam protection.
I am trying to build a proxy server in between my application and my smtp server. So when my application sends an email to some email id, my proxy server should catch it and change its "TO" address to my id and then send it to smtp server so that I'll get that message in my mail. This is a different case compared to reading messages from an inbox. I dont know how to distinguish each separate mail and get mail headers and body from each mail.
Any help would be greatly appreciated. Thanks in advance!
You should take a general look at JavaMail API and playing with it before asking for complete solutions.
Some other resources:
jGuru: Fundamentals of the JavaMail API
the JavaMail API - FAQ