2
votes

I'm using Google Spreadsheet for customers to send in comments. When they submit a comment, it gets emailed to me. I use the MailApp.sendEmail method. It works as expected except for the replyTo "advanced argument":

var myAdvancedArgs = { htmlBody: myHtmlBody, replyTo: customerEmail };
MailApp.sendEmail("[email protected]", "Comments Form", myBody, myAdvancedArgs);

customerEmail is set properly because I have it output correctly in the body of the message. htmlBody works as I do get the HTML version of the email displaying in my GMail account. However, when I click the reply button in GMail, the To: address is myself. It appears the replyTo is not being set at all. But then I look in the headers of the email message by clicking the little triangle next to my name with the tooltip "Show Details" and it does mention the correct reply-to address:

reply-to:    [email protected]

Is MailApp.sendEmail not setting the reply-to header correctly?

UPDATE: I've snipped a couple images to demonstrate what's happening. Either the reply-to header isn't set properly (maybe that's not how you do a reply to?) or GMail is not working properly for me.

First image, you see that there is a reply-to header created from my Google Spreadsheet script: Email from script with reply-to header set

Second image, when I click the reply button in GMail, the to address is not filled in with the address in the reply-to header: Bad reply to address

3

3 Answers

1
votes

I found the reason to your (and my) problem.

What you are seeing is a Gmail bug, not an Apps Script bug. Basically, if the reply-to is any email address that you have linked with your address so you can send mail as that account from within gmail, then reply-to is ignored. In other words, it will look broken to you, but for any other users of your script it will work properly. Non-Gmail users will see it work correctly in any case.

1
votes

This is an old question, but if I needed it maybe others also need it!

From my testing the replyTo worked only when I sent the mail not to the form Acount mail. If your form is on [email protected] acount send it to [email protected]

var reply = e.namedValues['Email'];

MailApp.sendEmail("[email protected]", "subject", "message",{"replyTo" : '"'+reply+'"'}); 
0
votes

Just tested like this :

function myFunction() {
    MailApp.sendEmail("[email protected] ", "test message",'empty body', {"replyTo" : "[email protected]"});   // replyTo son@insas
}

and it works as expected when I "reply" (using the reply button in gmail or in any mail client ) it shows up like this :

enter image description here

which is indeed the replyTo adress even if it is true that the sender is indeed the author of the script (which is also the expected behavior, see documentation about scripts)

So I'm afraid the issue you raised is invalid...