[英]Apps script does not send email containing links to Google Drive files on a given G Suite domain, no error message
Context语境
We are currently working on a short Apps script that sends links to Google Drive files (shared with anyone with the link) through the MailApp.sendEmail(options)
function.我们目前正在开发一个简短的应用程序脚本,该脚本通过
MailApp.sendEmail(options)
function 发送指向 Google Drive 文件的链接(与知道该链接的任何人共享)。
The script works well on our test G Suite domain but on the production domain, it just does not send the emails.该脚本在我们的测试 G Suite 域上运行良好,但在生产域上,它只是不发送电子邮件。 There are no error messages.
没有错误消息。
Some code一些代码
The issue can be reproduced through the following pieces of code:该问题可以通过以下代码段重现:
Code.gs file代码.gs 文件
function test_sendEmail() {
const template = HtmlService.createTemplateFromFile('template.html');
template.link = "https://drive.google.com";
template.title = "This is a link";
const mailBody = template.evaluate().getContent();
console.log("Quota: " + MailApp.getRemainingDailyQuota()); /* Quota is not exceeded. */
try {
const options = {
to: "myEmail@Address.com", /* Replace this with your email address */
subject: "LINK",
htmlBody: mailBody,
noReply: true
};
MailApp.sendEmail(options);
} catch(e) {
console.log(e.message);
}
}
template.html file模板.html文件
Link: <a href='<?= link ?>'><?= title ?></a>
What we tried我们尝试了什么
Emails are properly sent when the link does not contain the drive.google.com
part.当链接不包含
drive.google.com
部分时,电子邮件会正确发送。 For example, emails with links to google.com
are sent properly.例如,带有指向
google.com
链接的电子邮件可以正确发送。
We are able to send an email from the Gmail account the script is executed as and this email is sent properly with the Drive links.我们能够从 Gmail 帐户发送 email 脚本执行为,并且此 email 与驱动器链接正确发送。
As opposite as this question , I do not get "Message blocked" email and using GmailApp.sendEmail
instead of MailApp.sendEmail
does not seem to change anything.与这个问题相反,我没有收到“消息被阻止”email 并且使用
GmailApp.sendEmail
而不是MailApp.sendEmail
似乎没有任何改变。
Finally, the script above works well in the test G Suite domains and in some others we tried.最后,上面的脚本在测试 G Suite 域和我们尝试过的其他一些域中运行良好。
Thus, I believe that it comes from the G Suite domain configuration that have specific restrictions on Apps script.因此,我认为它来自对 Apps 脚本有特定限制的 G Suite 域配置。 Is it possible?
可能吗? Where can I change it in the G Suite admin console?
我可以在 G Suite 管理控制台的哪里进行更改? What other points should I check to make it work?
我还应该检查哪些其他点才能使其正常工作?
More details on the issue:有关该问题的更多详细信息:
sendEmail
method call is executed properly. sendEmail
方法调用后的代码正确执行。Dear Customers,<br/><br/>
We inform you that new documents are available. Please find them below:
<ul>
<? for(let i = 0; i < docs.length; i++) { ?>
<li>Document <a href='<?= docs[i].link ?>'><?= docs[i].title ?></a>, <i><?= docs[i].documentType ?></i> is available</li>
<? } ?>
</ul>
<br/>
Regards,<br/>
Your customer service.
Instead of MailApp use GmailApp (you might have to change the sendEmail parameters, check the docs)代替 MailApp 使用 GmailApp(您可能必须更改 sendEmail 参数,检查文档)
The above because others have being reported similar problems, actually something similar happened recently to me while working on client's project.以上是因为其他人被报告了类似的问题,实际上我最近在处理客户的项目时发生了类似的事情。
Related有关的
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.