Reputation: 2049
I've been working on an application that uses the Gmail API, but I've kind of hit a roadblock.
I need user Send-As information, but it doesn't appear to be available in the Gmail API. In Google Apps Accounts, the EmailSettings API provides this functionality, but it is unavailable for free gmail accounts.
I suppose my question is: Is there any way to pull a list of Send-As or POP-configured accounts from a regular Gmail account?
Upvotes: 1
Views: 461
Reputation: 112787
Sadly, you can not retrieve them from the Gmail API or any other API I know of. Other 3rd party applications that use the feature of "aliasing" their mail advise their users to first create the alias in the regular Gmail application first, and then input it manually.
You could do that, and in the background send a mail to the user's own inbox with the given alias. If the alias exists, it will be the sender of the mail. If it was incorrect, it will fall back to the regular email address.
You can now get the sendAs settings from the Gmail API:
Request
GET https://www.googleapis.com/gmail/v1/users/me/settings/sendAs?access_token={access_token}
Response
{
"sendAs": [
{
"sendAsEmail": "[email protected]",
"displayName": "",
"replyToAddress": "",
"signature": "",
"isPrimary": true,
"isDefault": true
},
{
"sendAsEmail": "[email protected]",
"displayName": "",
"replyToAddress": "",
"signature": "",
"isDefault": false,
"treatAsAlias": true,
"smtpMsa": {
"host": "host.com",
"port": 465,
"securityMode": "ssl"
},
"verificationStatus": "accepted"
}
]
}
Upvotes: 1