Google script to forward email to recipient - google-apps-script

While creating a rule in google admin I accidentally made a mistake and all the emails in my enterprise where sent to a specific email account. The emails skipped the inbox of the actual recipient and were sent to a global inbox.
Is there a script I can write to undo this meaning forwarding the email to the user who were suppose to receive this.

Related

MailApp.sendEmail() not sending from current user

I have an onEdit triggered appscript that grabs data from a spreadsheet, formats it and then sends it to an email address. Typically these messages would be sent 'from' the user that is triggering the script to run. However, I am experiencing strange behavior where the current user is not used to send the message - or used inconsistently.
A couple of notes:
Occasionally the message is sent by the current user, other times it is not (in those cases it comes from my account, which created the script)
Script trigger is an 'onEdit' script which monitors the sheet for a checkbox status change
Spreadsheet is in a Shared Drive
We are using Google apps for education
The recipient address is a mailing list tool. When I list a different email address as the recipient (internal, external, other) the message consistently comes from the current user as expected. I've no idea why the recipient would affect how Google sends the message.
I realize i could use the GmailApp library to send instead, but want to avoid the re-authorizations that are mentioned.

GAS MailApp allways sends a copy of email to script owner's email too

I just wanted to know if this behaviour is normal. Is it suppose to send a copy of the mail to me as the script owner, as well as the intended recipient? For example this code:
function emailTest(){
MailApp.sendEmail("someemail#gmail.com","test subject","test body");
}
Will send out an email to someemail#gmail.com. I will also get a copy in my inbox as the script owner. Can I shut this off somehow?
Regards,
Shumway
Because you're sending the mail from your account, you'll see the message in your 'Sent' box. If you're seeing it in your Inbox, it's not related to the script itself, as this is only sending to "someemail#gmail.com".
Things to check:
You don't have a forwarding rule from "someemail#gmail.com" to your account.
You don't have a filter/mail client/ other service accessing your inbox and placing your sent mail in the inbox.
You're not looking at 'All Mail'. Etc, etc.
You can probably get help for this at: https://productforums.google.com/forum/#!categories/apps/mail-settings.

Email verification using google app script and google forms

I have a google form app which has, among others, an email id field.I want to verify that the email entered by user is the email which belongs to him. Pls note: I DO NOT WANT TO VERIFY THE DOMAIN/SYNTAX OF EMAIL. All emails would be gmail ids, so if that helps, is there a way to send a mail validation link to their gmail accounts and on clicking the link, the entry is made to spreadsheet. Else its cancelled.
Also the link must be valid for limited time only.
Yes this is possible. You can publish a Google script as a web app and add the email address of the recipient as a query parameter to this app. When the user clicks the link, the app is called, the email is verified and the app itself can log an entry into the spreadsheet.

Google marks emails sent from spreadsheet with MailApp.sendEmail as phishing scam

I am using a variation of Google's MailApp.sendEmail() script ( https://developers.google.com/apps-script/articles/sending_emails) to send emails to addresses in a spreadsheet. To test the script I am sending them to another gmail account. However, the emails are being marked with the message: This message may not have been sent by: foo#gmail.com. Is there any way to avoid this? Thanks!
This warning isn't caused by the MailApp.sendMail() script. The phishing warning only shows up when I send email between two gmail accounts (both of which belong to me). It doesn't show up when I send email to other accounts using the MailApp.sendMail() script. The warning also appears when I send a standard gmail message from one account to the other, when the sending account is a consumer account, and the receiving account is a university account. The message does not appear on emails from other people's gmail addresses and does not appear on messages sent from my university account to my consumer account.

email forwarding removes original sender's email address in Google app scripts

Here's my Google App Script code:
var messages = threads[x].getMessages();
for (var y in messages)
{
messages[y].forward("someone#example.com");
}
This forwards fine, but it resets the from field of message to the email id of account which executes the script. This removes all credentials of the original sender of message. How to forward the email more elegantly such that all original headers (at least from and to) are retained? If the original message was sent to a list of people or a newsgroup, I need to retain it in the forwarded message.
In general a forwarded email does not retain the original from and to address. If you forward an email using GMail or Outlook you'll notice this. The GMailApp is behaving the same way.