I am trying to write a script that's gonna automaticaly forward a received email but at the same time change the sender (Gmail forwards messages with original sender). I have already tried the .forward function, but wasn't really able to change the sender.
2 Answers
0
votes
You may check the Managing Aliases documentation. You must create aliases prior to use. In some cases, users must also verify ownership of the alias. Aliases for external addresses should send mail through a remote SMTP mail sending agent (MSA). To configure the SMTP MSA for an alias, use the smtpMsa field to provide the connection details.
0
votes
This answer is correct that you must create aliases first.
But if you agree to settle on something less strict, as explained here, you can just use the advanced parameters name and replyTo:
var alt_name = 'Different name';
var reply_to = '[email protected]';
var to='[email protected]';
var obj = {replyTo: message.getFrom(), name: alt_name};
message.forward(recepient, obj);