Search code examples
javascriptgoogle-chrome-extensiongmailemail-headerscontent-script

How can I add an X-header field to Gmail header using javascript?


I'm writing a Chrome extension that builds on Gmail and which needs to add several proprietary header fields to the mail header before the message is sent. My app logic goes as follows: after the user composes a message in Gmail and presses Send button, code in the content script intercepts the Click event and I create the header fields. So my question is, how do I access the mail header where I can insert the new fields? I'm looking for something like Message.setHeader() in JavaMail and Android.


Solution

  • You can't. Gmail doesn't have a provision for the user to add any headers other than Reply-To.

    But, if you can show how to manually add a custom header, then we can show you how to automate that with a content script.

    Until then, to send an X-header, you'll have to use a different email client. Configure Thunderbird, for example, to use Gmail via IMAP.