当前位置: 首页>>代码示例>>Python>>正文


Python mail.EmailMessage方法代码示例

本文整理汇总了Python中google.appengine.api.mail.EmailMessage方法的典型用法代码示例。如果您正苦于以下问题:Python mail.EmailMessage方法的具体用法?Python mail.EmailMessage怎么用?Python mail.EmailMessage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在google.appengine.api.mail的用法示例。


在下文中一共展示了mail.EmailMessage方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: post

# 需要导入模块: from google.appengine.api import mail [as 别名]
# 或者: from google.appengine.api.mail import EmailMessage [as 别名]
def post(self):
    data = json.loads(self.request.body)
    ascii_name = data["name"].encode('ascii', errors='ignore')
    ascii_email = data["email"].encode('ascii', errors='ignore')
    ascii_subject = data["subject"].encode('ascii', errors='ignore')
    ascii_body = data["body"].encode('ascii', errors='ignore')

    replyto = '%s <%s>' % (ascii_name, ascii_email)
    message = mail.EmailMessage(sender=('MayOne no-reply <noreply@%s.appspotmail.com>' %
                                           model.Config.get().app_name),
                                reply_to=replyto,
                                subject=ascii_subject)
    message.to = "info@mayone.us"
    message.body = 'FROM: %s\n\n%s' % (ascii_email, ascii_body)
    message.send()
    util.EnableCors(self)
    self.response.write('Ok.') 
开发者ID:MayOneUS,项目名称:pledgeservice,代码行数:19,代码来源:main.py

示例2: send_approved_mail

# 需要导入模块: from google.appengine.api import mail [as 别名]
# 或者: from google.appengine.api.mail import EmailMessage [as 别名]
def send_approved_mail(sender_address):
    # [START send_message]
    message = mail.EmailMessage(
        sender=sender_address,
        subject="Your account has been approved")

    message.to = "Albert Johnson <Albert.Johnson@example.com>"
    message.body = """Dear Albert:

Your example.com account has been approved.  You can now visit
http://www.example.com/ and sign in using your Google Account to
access new features.

Please let us know if you have any questions.

The example.com Team
"""
    message.send()
    # [END send_message] 
开发者ID:GoogleCloudPlatform,项目名称:python-docs-samples,代码行数:21,代码来源:send_message.py

示例3: send_email

# 需要导入模块: from google.appengine.api import mail [as 别名]
# 或者: from google.appengine.api.mail import EmailMessage [as 别名]
def send_email(to_address, to_name, subject, body_html):
    """Sends an email from the configured address.
    Does not check for address validity.
    """

    if config.ALLOWED_EMAIL_TO_ADDRESSES is not None and \
       to_address not in config.ALLOWED_EMAIL_TO_ADDRESSES:
        # Not allowed to send to this address
        logging.info('send_email: not allowed to send to: %s' % to_address)
        return

    full_to_address = '%s <%s>' % (to_name, to_address)

    h2t = html2text.HTML2Text()
    h2t.body_width = 0
    body_text = h2t.handle(body_html)

    message = mail.EmailMessage(sender=config.MASTER_EMAIL_SEND_ADDRESS,
                                subject=subject,
                                to=full_to_address,
                                body=body_text,
                                html=body_html)

    message.send() 
开发者ID:adam-p,项目名称:danforth-east,代码行数:26,代码来源:gapps.py

示例4: _send_mail

# 需要导入模块: from google.appengine.api import mail [as 别名]
# 或者: from google.appengine.api.mail import EmailMessage [as 别名]
def _send_mail(to, subject, text_body, html_body, reply_to=None):
  """Deferred email task"""
  sender = ('Mayday PAC <noreply@%s.appspotmail.com>' %
            model.Config.get().app_name)
  message = mail.EmailMessage(sender=sender, subject=subject)
  message.to = to
  message.body = text_body
  message.html = html_body
  if reply_to:
    message.reply_to = reply_to
  else:
    message.reply_to = 'info@mayday.us'
  message.send() 
开发者ID:MayOneUS,项目名称:pledgeservice,代码行数:15,代码来源:env.py

示例5: test_remind

# 需要导入模块: from google.appengine.api import mail [as 别名]
# 或者: from google.appengine.api.mail import EmailMessage [as 别名]
def test_remind(self):
        """
        remind should send remind and mark job as done.
        """
        job = self.create_job(state='queued')
        with mock_instance('sndlatr.gmail.Mailman') as mailman:
            mail = mock.create_autospec(spec=gae_mail.EmailMessage)
            mailman.build_reply.return_value = mail
            job.remind('token')
            mailman.send_mail.assert_called_with(mail)
            mailman.build_reply.assert_called_with(job.thread_id_int,
                                                   mock.ANY)
            mailman.quit.assert_called_with()
        job = job.key.get()
        self.assertEquals(job.state, 'done') 
开发者ID:Schibum,项目名称:sndlatr,代码行数:17,代码来源:models_tests.py

示例6: _send_failure_notice

# 需要导入模块: from google.appengine.api import mail [as 别名]
# 或者: from google.appengine.api.mail import EmailMessage [as 别名]
def _send_failure_notice(job, subject_tpl, tpl_basepath, tpl_vars=None):
    message = mail.EmailMessage(sender=_sender,
                                to=job.user_email,
                                subject=subject_tpl.format(
                                    job.subject))
    localtime = _get_localtime(job)
    ctx = {'scheduled_at': localtime,
           'subject': job.subject}
    if tpl_vars is not None:
        ctx.update(tpl_vars)
    message.body = render_template('{}.txt'.format(tpl_basepath), **ctx)
    message.html = render_template('{}.html'.format(tpl_basepath), **ctx)
    logging.info(u'sending failure notice {} to {}'.format(
        tpl_basepath, job.user_email))
    message.send() 
开发者ID:Schibum,项目名称:sndlatr,代码行数:17,代码来源:mailnotify.py

示例7: build_remind_message

# 需要导入模块: from google.appengine.api import mail [as 别名]
# 或者: from google.appengine.api.mail import EmailMessage [as 别名]
def build_remind_message(remind_job):
    """
    Builds a reminder message for given remind_job.
    """
    message = mail.EmailMessage(sender=remind_job.user_email,
                                to=remind_job.user_email)
    ctx = {}
    message.body = render_template('reminder.txt', **ctx)
    message.html = render_template('reminder.html', **ctx)
    return message 
开发者ID:Schibum,项目名称:sndlatr,代码行数:12,代码来源:mailnotify.py

示例8: build_reply

# 需要导入模块: from google.appengine.api import mail [as 别名]
# 或者: from google.appengine.api.mail import EmailMessage [as 别名]
def build_reply(self, thread_id, mail=None):
        """
        Modify mail (gae mail.EmailMessage) to a reply of the given thread_id.
        If mail is None, creates a new, empty EmailMessage object.
        This looks up the last message in the given thread and modifies
        the References and Reply-To and subject headers of mail to be a reply
        to this message.
        """
        if mail is None:
            mail = gae_mail.EmailMessage()
        orig_msg = self.get_thread(thread_id, reverse=True, limit=1)
        if not orig_msg:
            raise MailNotFound('thread not found')
        orig_msg = orig_msg[0]

        # set References and In-Reply-To (see rfc rfc2822 3.6.4)
        orig_msg_id = orig_msg.get('rfc_message_id')
        if not orig_msg_id:
            raise RfcMsgIdMissing('Last mail in thread has no rfc message id')
        orig_references = orig_msg.get('references')
        if not orig_references:
            orig_references = orig_msg.get('in_reply_to')
        if not orig_references:
            orig_references = ''

        mail.headers = {'References': orig_references + '\r\n ' + orig_msg_id,
                        'In-Reply-To': orig_msg_id}
        mail.subject = orig_msg['subject']
        return mail 
开发者ID:Schibum,项目名称:sndlatr,代码行数:31,代码来源:gmail.py

示例9: send_mail

# 需要导入模块: from google.appengine.api import mail [as 别名]
# 或者: from google.appengine.api.mail import EmailMessage [as 别名]
def send_mail(self, mail):
        """ Sends gae mail.EmailMessage via SMTP. """
        smtp = self.open_smtp_session()
        smtp.send_rfc822(mail.to_mime_message())
        self.safe_smtp_quit(smtp) 
开发者ID:Schibum,项目名称:sndlatr,代码行数:7,代码来源:gmail.py

示例10: send

# 需要导入模块: from google.appengine.api import mail [as 别名]
# 或者: from google.appengine.api.mail import EmailMessage [as 别名]
def send(self, **kwargs):
        ''' Sends an email using the App Engine Mail API.
        
        Raises an InvalidEmailError if an invalid email address was specified.
        '''
        message = mail.EmailMessage(**kwargs)
        message.send() 
开发者ID:duo-labs,项目名称:isthislegit,代码行数:9,代码来源:email.py

示例11: test_handle_bounced_email

# 需要导入模块: from google.appengine.api import mail [as 别名]
# 或者: from google.appengine.api.mail import EmailMessage [as 别名]
def test_handle_bounced_email(testbed):
    handler = handle_incoming_email.LogSenderHandler()
    handler.request = 'request'
    message = mail.EmailMessage(
        sender='support@example.com',
        subject='Your account has been approved')
    message.to = 'Albert Johnson <Albert.Johnson@example.com>'
    message.body = 'Dear Albert.'
    handler.receive(message) 
开发者ID:GoogleCloudPlatform,项目名称:python-docs-samples,代码行数:11,代码来源:handle_incoming_email_test.py

示例12: _send_verification_email

# 需要导入模块: from google.appengine.api import mail [as 别名]
# 或者: from google.appengine.api.mail import EmailMessage [as 别名]
def _send_verification_email(self, user, email, reset_password=False):
            """Sends a verification email to a specific `user` with specific email details (in `email`). Creates a reset password link if `reset_password` is True."""

            # Prepare the verification URL
            user_id = user.get_id()
            token = self.user_model.create_signup_token(user_id)

            path_url = self.request.path_url
            path_url = path_url[:-len('verify')] if path_url.endswith('reset') else path_url
            path_url = path_url.rstrip('/')
            verification_params = { 'type': ('v' if not reset_password else 'p'), 'user_id': user_id, 'signup_token': token }
            verification_url = path_url + '/verify?' + urlencode(verification_params)

            # Prepare email body
            email['body_text'] = Template(email['body_text']).render(user=user, verification_url=verification_url)
            email['body_html'] = Template(email['body_html']).render(user=user, verification_url=verification_url)

            # Send the email
            if self.send_email_callback:
                # Use the provided function for sending the email
                self.send_email_callback(email)
            else:
                # Use GAE's email services
                message = mail.EmailMessage()
                message.sender = email['sender']
                message.to = user.email
                message.subject = email['subject']
                message.body = email['body_text']
                message.html = email['body_html']
                message.send() 
开发者ID:budowski,项目名称:rest_gae,代码行数:32,代码来源:users.py

示例13: send_appengine_email

# 需要导入模块: from google.appengine.api import mail [as 别名]
# 或者: from google.appengine.api.mail import EmailMessage [as 别名]
def send_appengine_email(sender, recipient, subject, body_html, body_text):
    email = EmailMessage()
    email.sender = sender
    email.to = recipient
    email.subject = subject
    email.body = body_text
    email.html = body_html
    email.send() 
开发者ID:Yelp,项目名称:love,代码行数:10,代码来源:email.py

示例14: Send

# 需要导入模块: from google.appengine.api import mail [as 别名]
# 或者: from google.appengine.api.mail import EmailMessage [as 别名]
def Send(subject, body, to=None, cc=None, bcc=None, html=False):
  """Sends an email.

  Args:
    subject: The email subject.
    body: The email body.
    to: The TO address(es). Can be either a string or list of strings, and each
        string can be either a username or email address.
    cc: The CC address(es). Can be either a string or list of strings, and each
        string can be either a username or email address.
    bcc: The BCC address(es). Can be either a string or list of strings, and
        each string can be either a username or email address.
    html: Whether the body contains HTML or plain text.

  Raises:
    NoRecipientsError: if the to, cc, and bcc arguments are all empty.
  """
  message = mail.EmailMessage(
      sender=_SENDER,
      reply_to=_REPLY_TO,
      subject='%s %s' % (_SUBJECT_PREFIX, subject))

  if html:
    message.html = body
  else:
    message.body = body

  to = _SanitizeAddrs(to)
  cc = _SanitizeAddrs(cc)
  bcc = _SanitizeAddrs(bcc)

  if to:
    message.to = to
  if cc:
    message.cc = cc
  if bcc:
    message.bcc = bcc

  # Make sure we're actually sending this to someone.
  recipients = sorted(list(set(to + cc + bcc)))
  if not recipients:
    raise NoRecipientsError

  try:
    logging.info('Sending email to %s', recipients)
    message.check_initialized()
    if env_utils.RunningInProd():
      message.send()

  # If something blows up, log it and move on. Failure to send an email is not
  # something that should take the caller off the rails.
  except Exception:  # pylint: disable=broad-except
    logging.exception('Error encountered while sending email') 
开发者ID:google,项目名称:upvote,代码行数:55,代码来源:mail_utils.py


注:本文中的google.appengine.api.mail.EmailMessage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。