我一直致力于使用Gmail API的应用程序,但我遇到了障碍。
我需要用户的Send-As信息,但它似乎无法在Gmail API中使用。在Google Apps帐户中,EmailSettings API提供此功能,但它不适用于免费的Gmail帐户。
我想我的问题是:是否有办法从常规Gmail帐户中提取发送方或POP配置的帐户列表?
答案 0 :(得分:1)
可悲的是,您无法从Gmail API或我知道的任何其他API 中检索它们。使用"别名"功能的其他第三方应用程序他们的邮件建议用户首先在常规Gmail应用程序中创建别名,然后手动输入。
您可以这样做,并在后台使用给定的别名向用户自己的收件箱发送邮件。如果别名存在,则它将是邮件的发件人。如果不正确,它将回退到常规电子邮件地址。
您现在可以获得sendAs settings from the Gmail API:
请求强>
GET https://www.googleapis.com/gmail/v1/users/me/settings/sendAs?access_token={access_token}
<强>响应强>
{
"sendAs": [
{
"sendAsEmail": "primary@gmail.com",
"displayName": "",
"replyToAddress": "",
"signature": "",
"isPrimary": true,
"isDefault": true
},
{
"sendAsEmail": "secondary@gmail.com",
"displayName": "",
"replyToAddress": "",
"signature": "",
"isDefault": false,
"treatAsAlias": true,
"smtpMsa": {
"host": "host.com",
"port": 465,
"securityMode": "ssl"
},
"verificationStatus": "accepted"
}
]
}