Gmail Api从别名发送 [英] Gmail Api send from alias

查看:38
本文介绍了Gmail Api从别名发送的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个脚本,该脚本使用OAuth 2.0与Gmail API连接.它运行完美,而且我能够从经过身份验证的帐户发送电子邮件.

I created a script that connects with the Gmail API using OAuth 2.0. It works perfectly, and I am able to send email from the authenticated account.

但是,我无法通过该帐户的任何别名发送电子邮件.如果我尝试这样做,则会收到以下错误消息:

However, I can't send email from any of the account's aliases. If I try to do so I get the following error message:

    "error": {
    "errors": [
            {
                "domain": "global",
                "reason": "forbidden",
                "message": "[ACCOUNT] does not have privileges to [ALIAS] mailbox."
            }
        ],
    "code": 403,
    "message": "[ACOUNT] does not have privileges to [ALIAS] mailbox."
    }
}

我已验证别名已在Gmail和Google Apps中设置.

I have verified that the alias is setup in Gmail and Google Apps.

有人有什么主意吗?

推荐答案

不要尝试将呼叫作为别名(例如,别名不应该作为用户ID出现在URL中),只需将别名电子邮件地址放入在发件人"中您发送的邮件中的标题.

Don't try to make the call as the alias (e.g. alias shouldn't be in the URL as the user ID), just put the alias email address in the "From" header in your sent message.

因此在python中将类似于:

so in python would be something like:

电子邮件=收件人:某人@ example.com \ r \ n发件人:myalias@gmail.com \ r \ n主题:等等\ r \ n \ r \ n有人在这里"

email = "To: someone@example.com\r\nFrom: myalias@gmail.com\r\nSubject: blah\r\n\r\nbody goes here"

gmail.users().messages().send(userId ="me",body = {'raw':base64.urlsafe_b64encode(email)})

gmail.users().messages().send(userId="me", body={'raw': base64.urlsafe_b64encode(email)})

这篇关于Gmail Api从别名发送的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆