Does GMAIL RESTful API support sending of non-ASCII emails addresses? - gmail

We have been using the GMAIL Restful APIs to send emails.
However, recently we have been receiving requests for support to send emails to non-ASCII email addresses.
I was able to use RFC2047 (Mime-encoded word) to properly encode the subject and the "from" email address headers. But using the same method for the "to"-recipient email addresses failed.
So my questions are :
Has anyone successfully sent emails to non-ASCII recipients using GMAIL RESTful APIs?
Or do we have any documentation i can read on how i can do this using the restful apis?
Thank you so very much for your time and I apologize in advance if this is a duplicate somewhere.

Workaround
This answer is posted as Community wiki as it is sourced be two great Stack Overflow answers on the topic.
At the moment of this answer, Gmail and other mailing services are still transitioning from only supporting ASCII characters to support UNICODE characters in the email addresses and subject forms. Therefore, you will need to encode your email address string in base64 to be able to send the emails.
This stack overflow answer clearly details everything related to how the domains and names of email addresses are being interpreted by mailing servers and the workaround to be able to send a email programatically to these addresses.
If you want a more specific Gmail API answer, this other Stack Overflow solution explains how you should encode your string to be able to send these non-ASCII emails.
I hope this has helped you. Let me know if you need anything else or if you did not understood something. :)

Related

Using Gmail API to update website when receiving an email

new to programming on the web so bear with me.
I've figured out that OAuth2.0 (the authorization protocol used by Gmail) is used for applications where Site A is given permission to information in Site B (in this case Gmail) by User X.
I am trying to create a website that updates when I receive an email from a specific sender. So, I am not using any of my website users' email information. I'm only using my own. I cannot seem to figure out (or even understand at a high level) how to permanently give my website access to my gmail account without doing some kind of user authentication on myself. What is the high-level process for giving my website this permanent authentication?
Let me know if I can make this clearer. Thank you in advance!
I've never done what you are trying to do, but you may find some useful answers here :)
Getting e-mail ID of sender while fetching mails from Gmail
I hope this helps if not I'm sorry. :)
UPDATE:
After reading that link a little bit more there are parts of it where they are getting the sender. You can always write a code to compare the sender by implementing what you need from that link. :)

Nodejs receiving email and redirecting to gmail email address

So i have an website, abc.com. If someone sends an email at support#abc.com i want to receive it at gmail address or whatever address i chose. Then if i reply to that email it in gmail then it should send either using gmail or mandrill. And from of the email should show up as support#abc.com.
This is my first time tackling email. And i have no clue.
So far i understand i need something to take emails in, send emails out, and then there is smtp server.
I get that nodemailer fulfils the role needed by two of the first things..But rest is confusing.
I know this sounds vague but as front end jquery dev i never thought of this much. So be patient and understand like with http protocol i have not much of understanding on this. This question could be many questions however i don't know what those question need to be.

How to send unicode characters in subject using Drafts.send in Gmail API?

If a user has created a draft in the gmail web UI that contains Unicode characters in the subject, calling Draft.Send seems to not handle these unicode characters correctly.
You can test this by:
Create a draft in gmail with the subject "snowman ☃"
Call drafts.list to get the draft id in the API explorer (https://developers.google.com/gmail/api/v1/reference/users/drafts/list#try-it)
Call Drafts.send using that draft id in the api explorer (https://developers.google.com/gmail/api/v1/reference/users/drafts/send#try-it)
Goto Gmail web ui, then the sent folder, and see that the email was sent with a subject of "snowman: ☃"
Any workarounds for this?
Using NodeJs, here is what I got it working for sending Unicode Characters along with emoji signs. Details in this comment
Email messages can only contain ASCII characters. See RFC 5335. Did you try encoding the subject?
Subject: =?utf-8?b?c25vd21hbiDimIM=?=
You didn't mention what language you're using but most have a library for performing the encoding.

SMTP Client - Send hidden information that can come back in a reply

I am using the nodemailer SMTP node module, a simple way to send emails through SMTP.
I am using this to send out text messages to various cell carriers, which will allow you to send a text message for free via email. An example email, which will text the Sprint phone (310) 987-6543:
3109876543#messaging.sprintpcs.com
These are all going out through one SMTP email address. This means all text replies from someone's phone will channel back to my email address.
A lot of people send these texts. I want to route the reply text back to the right person, using my own server side code.
The problem is distinguishing where the text came from. Ideally I could hide my own primary key ID for the sender in some sort of SMTP header, which would arrive at the recipients phone and come straight back in their text reply.
I don't really know anything about SMTP or email protocols - is this possible?
edit
As given in each of the answers below, in better email servers you can address to an email address as well as an extension to that address, such as:
// original email
sms-service#mysite.com
// extension
sms-service+a6e1087b#mysite.com
This would be a correct answer and would solve my problem, if only this worked in Exchange Server, which is the email server I am using. I don't know if there is a way to enable this or any other workaround.
Exchange server doesn't support plus addressing natively but it is possible do achieve this with a custom MTA, e.g. http://durdle.com/regexcatchall/
Source: https://serverfault.com/questions/195276/does-exchange-support-plussed-users-e-g-mynamespamexample-com-or-a-similar
Here are a few approaches that you might be able to use:
Unique from addresses
You could you use unique "from" or "reply-to" address for each each message (or for each recipient). For example "sms-service+a6e1087b#mysite.com". In that example, the hex would be a unique identifier that can be mapped to the conversation in your database.
Gmail supports such a scheme: emails targeted to [foo]+[whatever]#gmail.com will be delivered to [foo]#gmail.com and the receiver will know also get the [whatever] back. (more on this http://lifehacker.com/144397/instant-disposable-gmail-addresses)
Identify the user, not the conversation
One option is to not identify the conversation, but identify the phone number the reply comes back from instead. In many cases, the number from where the SMS reply was sent back from is enough to connect that message to the conversation. I'm sure the SMS gateway you're using will provide you with the number from where the reply came from.
Commercial SMS gateway
You can also opt to use a commercial SMS gateway (smsglobal.com comes to mind, though there are many others). These services have well defined APIs for sending a receiving replies. This naturally comes at a price, though. But along with the price, you do get more confidence as to the reliability of the service. A free SMS gateway might get shut down without much warning.
This common problem is traditionally implemented using the semantics of From: and Reply-To: headers of e-mails. This is in fact not (directly) related to SMTP, but rather to ARPA network text messages.
RFC 5322 is the current specification of these messages. It states:
When the "Reply-To:" field is present, it indicates the address(es) to which the author of the message suggests that replies be sent. In the absence of the "Reply-To:" field, replies SHOULD by default be sent to the mailbox(es) specified in the "From:" field unless otherwise specified by the person composing the reply.
So you simply need to encode the information you need into the Reply-To: header. Since you mention your own server-side code, you might be running an SMTP server yourself. In this case, you can put any address that will be routed to your SMTP server and encode the right person's address there.
Alternatively, if you rely on another SMTP server, you might want to use aliases. Postfix, and mail services such as GMail, typically allow address extensions, i.e. addresses of the form user+foo#domain.com, and you can encode the necessary information in the address extension.
For example, let's say that alice#domain.com wants to send a text to Sprint phone (310) 987-6543 through your service, you could send an e-mail to 3109876543#messaging.sprintpcs.com with:
Reply-To: alice%40domain.com#yourservice.com
Alternatively:
Reply-To: yourservice+alice%40domain.com#gmail.com
This will allow you to route the reply properly by looking at the destination of the reply e-mail.

sendmail: specify SMTP server and TLS options per message

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.

Resources