Gmail 设置 API 具有允许管理用户签名的方法,您可以在此处找到有关他们的信息 Manage signature
您应该知道,此 API 已弃用已被弃用,并将于 2019 年 10 月 16 日被拒绝。请尽快迁移到 Gmail API,以避免对您的应用程序造成干扰。
Gmail API
Manag signature settings 声明您应该使用 要在 Gmail API 中管理电子邮件签名,请使用 SendAs 资源。这将让您设置签名。
Python
我建议您关注python quick start 并尝试编辑它以与 sendAs 方法一起使用
from __future__ import print_function
from googleapiclient.discovery import build
from httplib2 import Http
from oauth2client import file, client, tools
# If modifying these scopes, delete the file token.json.
SCOPES = 'https://www.googleapis.com/auth/gmail.readonly'
def main():
"""Shows basic usage of the Gmail API.
Lists the user's Gmail labels.
"""
# The file token.json stores the user's access and refresh tokens, and is
# created automatically when the authorization flow completes for the first
# time.
store = file.Storage('token.json')
creds = store.get()
if not creds or creds.invalid:
flow = client.flow_from_clientsecrets('credentials.json', SCOPES)
creds = tools.run_flow(flow, store)
service = build('gmail', 'v1', http=creds.authorize(Http()))
# Call the Gmail API
results = service.users().labels().list(userId='me').execute()
labels = results.get('labels', [])
if not labels:
print('No labels found.')
else:
print('Labels:')
for label in labels:
print(label['name'])
if __name__ == '__main__':
main()