简体   繁体   中英

GmailApp not sending emails to gmail account every time

I am using this code to send emails (composing email content getting text from the sheet named ranges:

 //compose issue emails to student and admin function composeIssueEmail() { //student's name, last name and email var email = ss.getRangeByName("CourseProgressEmail").getValue() var name = ss.getRangeByName("CourseProgressName").getValue() var lastName = ss.getRangeByName("CourseProgressStudentLastName").getValue() var subj = ss.getRangeByName("SetUpIssueTitle").getValue() var subject = subj.replace("*imya*", name) var bodyText = ss.getRangeByName("SetUpIssueBody").getValue() var body = bodyText.replace("*imya*", name) var link = getChecksheetURL() var text = body.replace("*link*", link) //send email to student var studentEmail = sendEmail(email, subject, text) var adminEmail = "AGcourseSup@gmail.com" var adminSubj = ss.getRangeByName("SetUpAdminIssueTitle").getValue() var adminSubject = adminSubj.replace("*imya*", name) var adminSubjectFinal = adminSubject.replace("*familia*", lastName) var adminText = ss.getRangeByName("SetUpAdminIssueBody").getValue() var adminTextReplace = adminText.replace("*imia*", name) var adminBody = adminTextReplace.replace("*familia*", lastName) var adminText = adminBody.replace("*link*", link) //send email to admin sendEmail(adminEmail, adminSubjectFinal, adminText) } //gets current checksheet URL function getChecksheetURL() { var Url = ss.getUrl() var linkMiddle = "#gid=" var sheetID = sheet.getSheetId() var shecksheetURL = Url + linkMiddle + sheetID return shecksheetURL } //sends emails function sendEmail(email, subject, body) { GmailApp.sendEmail(email, subject, body) } 

Execution transcript: [19-06-12 16:39:43:396 EEST] Execution succeeded [2.399 seconds total runtime]

It sends stably to the gmail account that is the same as spreadsheet's one.

But to another gmail account it sends about every other time.

Details:

  • This code is executed (I log the line after this code)

  • The emails are visible in my outbound box but not arriving to any of the boxes of the recepient gmail.

  • Not in spam etc.

  • I don't get any messages, error or bounce notifications.

I tried MailApp instead - it's even worse and sometimes doesn't send even to my own email.

I tried to change things in settings config, but didn't find anything to work.

I set up a filter "never send to spam" and "always star it" - didn't work.

I deleted a link from it so it has no link - didn't work.

What can be a solution?

I handled this issue. The issue is about anti-spam filters not about the code.

I gained more trust to the email account by adding "Reply To" option within GmailApp.sendEmail method. It magically solved the problem so each email reaches target now.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM