![](/img/trans.png)
[英]How to send email of a G-Suite/Workspace alias domain externally (e.g. via Ubuntu)
[英]Apps script does not send email containing links to Google Drive files on a given G Suite domain, no error message
语境
我们目前正在开发一个简短的应用程序脚本,该脚本通过MailApp.sendEmail(options)
function 发送指向 Google Drive 文件的链接(与知道该链接的任何人共享)。
该脚本在我们的测试 G Suite 域上运行良好,但在生产域上,它只是不发送电子邮件。 没有错误消息。
一些代码
该问题可以通过以下代码段重现:
代码.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);
}
}
模板.html文件
Link: <a href='<?= link ?>'><?= title ?></a>
我们尝试了什么
当链接不包含drive.google.com
部分时,电子邮件会正确发送。 例如,带有指向google.com
链接的电子邮件可以正确发送。
我们能够从 Gmail 帐户发送 email 脚本执行为,并且此 email 与驱动器链接正确发送。
与这个问题相反,我没有收到“消息被阻止”email 并且使用GmailApp.sendEmail
而不是MailApp.sendEmail
似乎没有任何改变。
最后,上面的脚本在测试 G Suite 域和我们尝试过的其他一些域中运行良好。
因此,我认为它来自对 Apps 脚本有特定限制的 G Suite 域配置。 可能吗? 我可以在 G Suite 管理控制台的哪里进行更改? 我还应该检查哪些其他点才能使其正常工作?
有关该问题的更多详细信息:
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.
代替 MailApp 使用 GmailApp(您可能必须更改 sendEmail 参数,检查文档)
以上是因为其他人被报告了类似的问题,实际上我最近在处理客户的项目时发生了类似的事情。
有关的
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.