【问题标题】:SMTP in Google ScriptsGoogle 脚本中的 SMTP
【发布时间】:2015-01-24 03:37:46
【问题描述】:

我编写了一个 Google 脚本来在某个时间发送电子邮件。 所以现在它可以正常从"example@gmail.com" 发送。目前example@gmail.com's 有权从mail@example.com 发送/接收电子邮件。但是当我想安排来自mail@example.com 的电子邮件时,脚本不起作用

我浏览了 Google 的文档 GmailApp.sendEmail(message.getTo(), message.getSubject(), body, options);,发现 sendEmail 没有来自。我想知道如何解决这个问题。

我已尝试将其设置为来自mail@example.com 的电子邮件草稿,尝试将默认用户设置为mail@example.com,但仍然无法正常工作。

【问题讨论】:

    标签: google-apps-script


    【解决方案1】:

    我假设您有别名。这就是您作为别名发送的方式

    var aliases = GmailApp.getAliases();
    Logger.log(aliases);
    GmailApp.sendEmail(message.getTo(), message.getSubject(), body, {'from': aliases[0]});
    

    【讨论】:

      【解决方案2】:

      如果您的代码发送的消息当前位于您的 drafts 文件夹中,您可以使用 How to send a draft email using google apps script 中的技术发送消息,并在 From: 字段中保留别名。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2021-10-04
        • 1970-01-01
        • 2016-04-10
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多