2

我正在尝试将收到的电子邮件限制在我的应用程序中,因此它只接受来自谷歌群组成员的邮件。更具体地说,我只想将电子邮件的内容添加到我的数据存储区(如果它们是组的一部分)。我在这里找到了 hasMember/IsMember 方法:https ://developers.google.com/admin-sdk/directory/v1/reference/members/hasMember并认为这可能是我正在寻找的,但我不知道如何使用它,因为他们没有提供示例,我对此很陌生。

这将是用于此的正确 API 吗?这是我的传入邮件处理程序代码,我添加了 IF 语句注释以显示我想要做什么:

import webapp2
import logging
from google.appengine.ext.webapp import mail_handlers
from google.appengine.api import mail
import os
from main import WorkRequest
import re


class IncomingMailHandler(mail_handlers.InboundMailHandler):
    def receive(self, message):
        (encoding, payload) = list(message.bodies(content_type='text/plain'))[0]
        body_text = payload.decode()
        logging.info('Received email message from %s, subject "%s": %s' %
                     (message.sender, message.subject, body_text))

        logging.info (message.sender)
        logging.info(message.subject)
        logging.info(body_text)


        #IF MESSAGE_SENDER == MEMBER OF GOOGLE GROUP:

            wr = WorkRequest()

            wr.email = message.sender
            wr.userId = None
            wr.title = message.subject
            wr.content = body_text
            wr.status = "OPEN"
            wr.submission_type = "EMAIL"
            wr.assigned_to = "UNASSIGNED"
            wr.put()

application = webapp2.WSGIApplication([('/_ah/mail/.+', IncomingMailHandler)],debug=True)
4

0 回答 0