3

I'm trying to set up an integration with a help desk system that allows for us to automatically assign it to certain queues by either parsing the subject header or if it comes from a specific address.

Ideally I'd like people to be able to email a specific address and then this get forwarded to the helpdesk system's email address which can then add it to a specific queue.

However, I can't seem to find a way to both preserve the original sender (so the original user can be directly contacted and assigned to the ticket) and change the subject to add something that can be parsed by the system.

Using Gmail's auto forwarder will preserve the sender but I have no control of the subject header (or anything actually). Using Apps Script or IFTTT I can change the subject of the email and then forward it on to the right email address but then the email will be sent from the forwarding address rather than the original sender.

Is there a way to preserve the original sender's address but change the subject header? I was half hoping that I could fake the from: header using Apps Script but that doesn't appear to be possible other than from aliases of the Gmail account.

2
  • This sounds like something that should not be possible. Imagine someone changing the subject of an email you sent to something offensive and forwarding it in a way as if it comes from you...
    – user79865
    Jul 22, 2015 at 21:48
  • SMTP does absolutely no validation of headers and they can be set including the from header. I could easily email you from [email protected] unless my mail server enforced something (which gmail does) or if another mail server en route decided that my mail server shouldn't be sending stuff from the stackoverflow.com domain and figured it might be spam.
    – ydaetskcoR
    Jul 22, 2015 at 23:11

2 Answers 2

2

Short answer

Sending an email with an email from another user, in other words that you don't know they SMTP settings, is not possible with Gmail.

Explanaition

The feature of sending email messages from other addresses through the Google email servers was removed so, at this time, it's required that you know the email SMTP settings of the account that you want to use to send email messages.

By the other hand, if the email SMTP is not secure enough could be blocked by Gmail security filters (anti-spam, anti-spoofing, anti-impersonation, etc.). Example of security features of modern email services:

Alternatives

The "right way" is to use/build a help desk solution or CRM that includes features to assign email messages to variable pipelines without using SMTP. Further details on these are out of the scope of this site.

It's worth to say that there other sites in the StackExchange network that could be help you

References

Spam takes another hit: email authentication now available to millions of Google Apps customers - Official Google for Work Blog

2

Changing the "replyTo" instead of the "from" may work in your scenario.

You should be able to customize both the Subject and the replyTo in a Google Apps Script.

So, here are the components and steps. (It appears that you know most of this, but here it is for the benefit of others.)

  1. An external person sends an email to a specific address. (Preferably an alias for one Google email account, so that you won't have to do any setup for the following steps for any more than that account.)
  2. There is a Google Apps script within the Google Account for that email. It is set through its "trigger" to be executed every minute (or five minutes, or whatever).
  3. During each execution, the script iterates through messages that the email account has received. (To do so, it uses the GmailApp and GmailMessage classes.) It uses the email's To address to determine what you want to put in the forwarded message's subject. Then it uses the GmailMessage.forward(recipient,options) method to forward the message with the new subject and with a "replyTo" set to the original message's From address.
  4. Your help desk system would then parse the subject and send the message -- with its new "replyTo" header -- to the appropriate queue.

Instead of changing the subject you could also have the forwarded message sent from one of the account's aliases and then your help desk system could key off that from instead of the subject.

Of course, if the help system won't use the replyTo address then this won't work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.