Python google.appengine.api.mail.send_mail() Examples

The following are code examples for showing how to use google.appengine.api.mail.send_mail(). They are from open source Python projects. You can vote up the examples you like or vote down the ones you don't like.

Example 1
Project: ForexApp   Author: yaakov300   File: symbolGraph.py    MIT License 6 votes vote down vote up
def sendMailAlert(arrayMail,pofitOrLoss):

     user_address = "[email protected]"
     senderadress = arrayMail['userMail']
     name = "ForexApp-Alert"
     comment = "Hello " + arrayMail['username'] + "\n\n"
     if(pofitOrLoss == "good"): #transaction was completed successfully
        comment = comment + "Your transaction has been completed successfully" + "\n"
     else:#transaction was failed
        comment = comment + "Your transaction has been failed" + "\n"
     comment = comment + "\tsymbol:" + arrayMail['symbol'] + "\n" +\
        "\tType: " + str(arrayMail['type']) + "\n" +\
        "\tEnter Price: " + str(arrayMail['enPrice']) + "\n" +\
        "\tTake Profit: " + str(arrayMail['taPro']) + "\n" +\
        "\tStop Loss: " + str(arrayMail['stLoss']) + "\n" +\
        "\tVolume: " + str(arrayMail['volume']) + "\n\n" +\
        "Thank you!\n  ForexApp"
     mail.send_mail(user_address, senderadress,  name , comment) 
Example 2
Project: ForexApp   Author: yaakov300   File: forgetPass.py    MIT License 6 votes vote down vote up
def post(self):
        template_params = {}
        mail_forget = self.request.get("mailforget")
        user = User.query(User.mail == mail_forget).get()

        if not user:
            template_params['error'] = '* Email address does not exist!'
            html = template.render("web/templates/forgetPass.html", template_params)
            self.response.write(html)

        else:

          sender_address ='[email protected]'
          user_address = mail_forget
          print mail_forget
          subject = 'Forgot password or User Name?'
          username= user.username
          code = user.user_code
          code = str(code)

          body = 'Hello ' + username + '\n'+'Update new password here: http://youforrexapp.appspot.com/UpdatePass' + '\nUse this user code:' + code

          mail.send_mail(sender_address,user_address, subject, body)
          html = template.render("web/templates/login.html", template_params)
          self.response.write(html) 
Example 3
Project: github-stats   Author: lipis   File: task.py    MIT License 6 votes vote down vote up
def send_mail_notification(subject, body, to=None, **kwargs):
  if not config.CONFIG_DB.feedback_email:
    return
  brand_name = config.CONFIG_DB.brand_name
  sender = '%s <%s>' % (brand_name, config.CONFIG_DB.feedback_email)
  subject = '[%s] %s' % (brand_name, subject)
  if config.DEVELOPMENT:
    logging.info(
      '\n'
      '######### Deferring sending this email: #############################'
      '\nFrom: %s\nTo: %s\nSubject: %s\n\n%s\n'
      '#####################################################################',
      sender, to or sender, subject, body
    )
  deferred.defer(mail.send_mail, sender, to or sender, subject, body, **kwargs)


###############################################################################
# Admin Notifications
############################################################################### 
Example 4
Project: gae-init-magic   Author: gae-init   File: task.py    MIT License 6 votes vote down vote up
def send_mail_notification(subject, body, to=None, **kwargs):
  if not config.CONFIG_DB.feedback_email:
    return
  brand_name = config.CONFIG_DB.brand_name
  sender = '%s <%s>' % (brand_name, config.CONFIG_DB.feedback_email)
  subject = '[%s] %s' % (brand_name, subject)
  if config.DEVELOPMENT:
    logging.info(
      '\n'
      '######### Deferring sending this email: #############################'
      '\nFrom: %s\nTo: %s\nSubject: %s\n\n%s\n'
      '#####################################################################',
      sender, to or sender, subject, body
    )
  deferred.defer(mail.send_mail, sender, to or sender, subject, body, **kwargs)


###############################################################################
# Admin Notifications
############################################################################### 
Example 5
Project: vote4code   Author: welovecoding   File: task.py    MIT License 6 votes vote down vote up
def send_mail_notification(subject, body, to=None, **kwargs):
  if not config.CONFIG_DB.feedback_email:
    return
  brand_name = config.CONFIG_DB.brand_name
  sender = '%s <%s>' % (brand_name, config.CONFIG_DB.feedback_email)
  subject = '[%s] %s' % (brand_name, subject)
  if config.DEVELOPMENT:
    logging.info(
      '\n'
      '######### Deferring to send this email: #############################'
      '\nFrom: %s\nTo: %s\nSubject: %s\n\n%s\n'
      '#####################################################################',
      sender, to or sender, subject, body
    )
  deferred.defer(mail.send_mail, sender, to or sender, subject, body, **kwargs)


###############################################################################
# Admin Notifications
############################################################################### 
Example 6
Project: tichu-tournament   Author: aragos   File: results_email_handler.py    MIT License 6 votes vote down vote up
def _SendEmailToAddress(self, user, sender_address, player_email, unnamed_email_text,
      unnamed_email_html, player_greeting, attachment_files):
    """ Sends an email to the specifie address.

    Args:
      user: Tournament director, currently logged in user.
      sender_address: String. Address to send email from.
      player_email: String. Addressee's email.
      unnamed_email_text: String. Body of the email without the player's greeting.
      unnamed_email_html: String. HTML version of the email without the player's
        greeting.
      player_greeting: String. How to address the player.
      attachment_files: List of Attachment payloads to include.
    """
    email_text = "{}{}".format(player_greeting, unnamed_email_text)
    email_html = "{}<br/><br/>{}".format(player_greeting, unnamed_email_html)
    mail.send_mail(
      sender=sender_address,
      to=player_email,
      subject="Tichu Tournament Results",
      body=email_text,
      html=email_html,
      attachments=attachment_files,
      reply_to=user.email()) 
Example 7
Project: crypto-pocket   Author: lipis   File: task.py    MIT License 6 votes vote down vote up
def send_mail_notification(subject, body, to=None, **kwargs):
  if not config.CONFIG_DB.feedback_email:
    return
  brand_name = config.CONFIG_DB.brand_name
  sender = '%s <%s>' % (brand_name, config.CONFIG_DB.feedback_email)
  subject = '[%s] %s' % (brand_name, subject)
  if config.DEVELOPMENT:
    logging.info(
      '\n'
      '######### Deferring to send this email: #############################'
      '\nFrom: %s\nTo: %s\nSubject: %s\n\n%s\n'
      '#####################################################################',
      sender, to or sender, subject, body
    )
  deferred.defer(mail.send_mail, sender, to or sender, subject, body, **kwargs)


###############################################################################
# Admin Notifications
############################################################################### 
Example 8
Project: dturmscrap   Author: aktech   File: dturm.py    MIT License 6 votes vote down vote up
def run_rmscrap():
    br = open_browser(rm_url)
    br.select_form(predicate=select_form)
    login(br, roll_no, password)

    # GET News
    allnews = get_news(br)
    latestnews = latest_news(allnews)
    if latestnews:
        save_news(allnews)
        logging.info('Saved News: %s', allnews)

    # SEND Latest News
    body = '\n'.join(latestnews)
    if body:
        mail.send_mail(sender_address, user_address, subject, body)
        logging.info("Mail Sent!")
    else:
        logging.info("No Latest News Found") 
Example 9
Project: hashtagtodo   Author: slackpad   File: app_user.py    MIT License 6 votes vote down vote up
def delete():
    if request.method == 'POST':
        dos = arrow.get(g.user.created).humanize()
        calendars = len([c for c in Calendar.query(ancestor=g.user.key)])
        todos = len([e for e in Event.query(ancestor=g.user.key)])
        subject = '%s %s closed their account' % (g.user.first_name, g.user.last_name)
        body = '''
%s (joined %s, made %d todos and had %d calendars)

%s
''' % (g.user.email, dos, todos, calendars, request.form.get('feedback'))
        mail.send_mail(sender=EMAILS['alerts'], to=EMAILS['support'], subject=subject, body=body)

        calendars = Calendar.get_all(g.user.key)
        for calendar in calendars:
            for event in Event.get_all(calendar.key):
                event.key.delete()
            calendar.key.delete()

        User.unindex(g.user.key.urlsafe())
        g.user.key.delete()
        session.pop('user', None)
        return redirect('/index.html')

    return render_template('delete.html') 
Example 10
Project: that-startpage-rocks   Author: the-duck   File: main.py    GNU Lesser General Public License v3.0 6 votes vote down vote up
def send_mail():

    fn = request.form['firstname']
    ln = request.form['lastname']
    e = request.form['email']
    b = request.form['body']
    footer = "\n\n------- [Sent by this person via That Startpage Rocks' contact form] ----------\n{0} {1} <{2}>".format(fn, ln, e)

    theBody = "{0}\n{1}".format(b,footer)

    mail.send_mail(sender= "Sender <[email protected]>",
              to="Mark Spurgeon <[email protected]>",
              subject="[RockerBot] Contacted from That Startpage Rocks",
              body=theBody)
    return redirect(url_for('sent_mail'))
#####
# Errors
#### 
Example 11
Project: python-docs-samples   Author: GoogleCloudPlatform   File: send_mail.py    Apache License 2.0 6 votes vote down vote up
def send_approved_mail(sender_address):
    # [START send_mail]
    mail.send_mail(sender=sender_address,
                   to="Albert Johnson <[email protected]>",
                   subject="Your account has been approved",
                   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
""")
    # [END send_mail] 
Example 12
Project: python-docs-samples   Author: GoogleCloudPlatform   File: user_signup.py    Apache License 2.0 6 votes vote down vote up
def post(self):
        user_address = self.request.get('email_address')

        if not mail.is_email_valid(user_address):
            self.get()  # Show the form again.
        else:
            confirmation_url = create_new_user_confirmation(user_address)
            sender_address = (
                'Example.com Support <{}@appspot.gserviceaccount.com>'.format(
                    app_identity.get_application_id()))
            subject = 'Confirm your registration'
            body = """Thank you for creating an account!
Please confirm your email address by clicking on the link below:

{}
""".format(confirmation_url)
            mail.send_mail(sender_address, user_address, subject, body)
# [END send-confirm-email]
            self.response.content_type = 'text/plain'
            self.response.write('An email has been sent to {}.'.format(
                user_address)) 
Example 13
Project: luci-py   Author: luci   File: ui.py    Apache License 2.0 6 votes vote down vote up
def _email_html(to, subject, body):
  """Sends an email including a textual representation of the HTML body.

  The body must not contain <html> or <body> tags.
  """
  mail_args = {
    'body': saxutils.unescape(re.sub(r'<[^>]+>', r'', body)),
    'html': '<html><body>%s</body></html>' % body,
    'sender': '[email protected]%s.appspotmail.com' % app_identity.get_application_id(),
    'subject': subject,
  }
  try:
    if to:
      mail_args['to'] = to
      mail.send_mail(**mail_args)
    else:
      mail.send_mail_to_admins(**mail_args)
    return True
  except mail_errors.BadRequestError:
    return False 
Example 14
Project: luci-py   Author: luci   File: ui.py    Apache License 2.0 6 votes vote down vote up
def _email_html(to, subject, body):
  """Sends an email including a textual representation of the HTML body.

  The body must not contain <html> or <body> tags.
  """
  mail_args = {
    'body': saxutils.unescape(re.sub(r'<[^>]+>', r'', body)),
    'html': '<html><body>%s</body></html>' % body,
    'sender': '[email protected]%s.appspotmail.com' % app_identity.get_application_id(),
    'subject': subject,
  }
  try:
    if to:
      mail_args['to'] = to
      mail.send_mail(**mail_args)
    else:
      mail.send_mail_to_admins(**mail_args)
    return True
  except mail_errors.BadRequestError:
    return False 
Example 15
Project: luci-py   Author: luci   File: ui.py    Apache License 2.0 6 votes vote down vote up
def _email_html(to, subject, body):
  """Sends an email including a textual representation of the HTML body.

  The body must not contain <html> or <body> tags.
  """
  mail_args = {
    'body': saxutils.unescape(re.sub(r'<[^>]+>', r'', body)),
    'html': '<html><body>%s</body></html>' % body,
    'sender': '[email protected]%s.appspotmail.com' % app_identity.get_application_id(),
    'subject': subject,
  }
  try:
    if to:
      mail_args['to'] = to
      mail.send_mail(**mail_args)
    else:
      mail.send_mail_to_admins(**mail_args)
    return True
  except mail_errors.BadRequestError:
    return False 
Example 16
Project: luci-py   Author: luci   File: ui.py    Apache License 2.0 6 votes vote down vote up
def _email_html(to, subject, body):
  """Sends an email including a textual representation of the HTML body.

  The body must not contain <html> or <body> tags.
  """
  mail_args = {
    'body': saxutils.unescape(re.sub(r'<[^>]+>', r'', body)),
    'html': '<html><body>%s</body></html>' % body,
    'sender': '[email protected]%s.appspotmail.com' % app_identity.get_application_id(),
    'subject': subject,
  }
  try:
    if to:
      mail_args['to'] = to
      mail.send_mail(**mail_args)
    else:
      mail.send_mail_to_admins(**mail_args)
    return True
  except mail_errors.BadRequestError:
    return False 
Example 17
Project: luci-py   Author: luci   File: ui.py    Apache License 2.0 6 votes vote down vote up
def _email_html(to, subject, body):
  """Sends an email including a textual representation of the HTML body.

  The body must not contain <html> or <body> tags.
  """
  mail_args = {
    'body': saxutils.unescape(re.sub(r'<[^>]+>', r'', body)),
    'html': '<html><body>%s</body></html>' % body,
    'sender': '[email protected]%s.appspotmail.com' % app_identity.get_application_id(),
    'subject': subject,
  }
  try:
    if to:
      mail_args['to'] = to
      mail.send_mail(**mail_args)
    else:
      mail.send_mail_to_admins(**mail_args)
    return True
  except mail_errors.BadRequestError:
    return False 
Example 18
Project: meet-notes   Author: lipis   File: task.py    MIT License 6 votes vote down vote up
def send_mail_notification(subject, body, to=None, **kwargs):
  if not config.CONFIG_DB.feedback_email:
    return
  brand_name = config.CONFIG_DB.brand_name
  sender = '%s <%s>' % (brand_name, config.CONFIG_DB.feedback_email)
  subject = '[%s] %s' % (brand_name, subject)
  if config.DEVELOPMENT:
    logging.info(
      '\n'
      '######### Deferring to send this email: #############################'
      '\nFrom: %s\nTo: %s\nSubject: %s\n\n%s\n'
      '#####################################################################'
      % (sender, to or sender, subject, body)
    )
  deferred.defer(mail.send_mail, sender, to or sender, subject, body, **kwargs)


###############################################################################
# Admin Notifications
############################################################################### 
Example 19
Project: wodore-gae   Author: wodore   File: task.py    MIT License 6 votes vote down vote up
def send_mail_notification(subject, body, to=None, **kwargs):
  if not config.CONFIG_DB.feedback_email:
    return
  brand_name = config.CONFIG_DB.brand_name
  sender = '%s <%s>' % (brand_name, config.CONFIG_DB.feedback_email)
  subject = '[%s] %s' % (brand_name, subject)
  if config.DEVELOPMENT:
    logging.info(
        '\n'
        '######### Deferring to send this email: #############################'
        '\nFrom: %s\nTo: %s\nSubject: %s\n\n%s\n'
        '#####################################################################'
        % (sender, to or sender, subject, body)
      )
  deferred.defer(mail.send_mail, sender, to or sender, subject, body, **kwargs)


###############################################################################
# Admin Notifications
############################################################################### 
Example 20
Project: birwaz   Author: manshar   File: task.py    MIT License 6 votes vote down vote up
def send_mail_notification(subject, body, to=None, **kwargs):
  if not config.CONFIG_DB.feedback_email:
    return
  brand_name = config.CONFIG_DB.brand_name
  sender = '%s <%s>' % (brand_name, config.CONFIG_DB.feedback_email)
  subject = '[%s] %s' % (brand_name, subject)
  if config.DEVELOPMENT:
    logging.info(
      '\n'
      '######### Deferring to send this email: #############################'
      '\nFrom: %s\nTo: %s\nSubject: %s\n\n%s\n'
      '#####################################################################',
      sender, to or sender, subject, body
    )
  deferred.defer(mail.send_mail, sender, to or sender, subject, body, **kwargs)


###############################################################################
# Admin Notifications
############################################################################### 
Example 21
Project: python-compat-runtime   Author: GoogleCloudPlatform   File: report_generator.py    Apache License 2.0 6 votes vote down vote up
def SendReport(self, report):
    """Emails an exception report.

    Args:
      report: A string containing the report to send.
    """
    subject = ('Daily exception report for app "%s", major version "%s"'
               % (self.app_id, self.major_version))
    report_text = saxutils.unescape(re.sub('<[^>]+>', '', report))
    mail_args = {
        'sender': self.sender,
        'subject': subject,
        'body': report_text,
        'html': report,
    }
    if self.to:
      mail_args['to'] = self.to
      self.send_mail(**mail_args)
    else:
      self.send_mail_to_admins(**mail_args) 
Example 22
Project: electron-crash-reporter   Author: lipis   File: task.py    MIT License 6 votes vote down vote up
def send_mail_notification(subject, body, to=None, **kwargs):
  if not config.CONFIG_DB.feedback_email:
    return
  brand_name = config.CONFIG_DB.brand_name
  sender = '%s <%s>' % (brand_name, config.CONFIG_DB.feedback_email)
  subject = '[%s] %s' % (brand_name, subject)
  if config.DEVELOPMENT:
    logging.info(
      '\n'
      '######### Deferring to send this email: #############################'
      '\nFrom: %s\nTo: %s\nSubject: %s\n\n%s\n'
      '#####################################################################'
      % (sender, to or sender, subject, body)
    )
  deferred.defer(mail.send_mail, sender, to or sender, subject, body, **kwargs)


###############################################################################
# Admin Notifications
############################################################################### 
Example 23
Project: oppia   Author: google-code-export   File: gae_email_services.py    Apache License 2.0 6 votes vote down vote up
def send_mail_to_admin(sender, subject, body):
    """Enqueues a 'send email' request with the GAE mail service.

    Args:
      - sender: str. the email address of the sender, usually in the form
          'SENDER NAME <[email protected]>.
      - subject: str. The subject line of the email.
      - body: str. The plaintext body of the email.
    """
    if feconf.CAN_SEND_EMAILS_TO_ADMIN:
        if not mail.is_email_valid(feconf.ADMIN_EMAIL_ADDRESS):
            raise Exception(
                'Malformed email address: %s' %
                feconf.ADMIN_EMAIL_ADDRESS)

        app_id = app_identity.get_application_id()
        body = '(Sent from %s)\n\n%s' % (app_id, body)

        mail.send_mail(sender, feconf.ADMIN_EMAIL_ADDRESS, subject, body)
        counters.EMAILS_SENT.inc() 
Example 24
Project: loaner   Author: google   File: process_emails.py    Apache License 2.0 5 votes vote down vote up
def post(self):
    """Processes POST request."""
    kwargs = self.request.params.items()
    email_dict = {}
    for key, value in kwargs:
      email_dict[key] = value

    try:
      mail.send_mail(**email_dict)
    except mail.InvalidEmailError as error:
      logging.error(
          'Email helper failed to send mail due to an error: %s. (Kwargs: %s)',
          error.message, kwargs) 
Example 25
Project: ForexApp   Author: yaakov300   File: mai.py    MIT License 5 votes vote down vote up
def get(self):
        user_address = "[email protected]"
        senderadress = "[email protected]"
        name = "yaacov the king"
        comment = "temani is work"
       #mail.send_mail(senderadress, senderadress, "name: " + name + " mail: " + user_address , comment) 
Example 26
Project: ForexApp   Author: yaakov300   File: support.py    MIT License 5 votes vote down vote up
def post(self):
        template_params = {}
        user_address = self.request.get("mail")
        senderadress = "[email protected]>"
        name = self.request.get("name")
        comment = self.request.get("comment")
        if not mail.is_email_valid(user_address):
            self.response.out.write("mail is wrong:"+ user_address+name+comment +senderadress)
        else:
            mail.send_mail(senderadress, senderadress, "name: " + name + " mail: " + user_address , comment)
            html = template.render("web/templates/Thankyou.html", template_params)
            self.response.write(html) 
Example 27
Project: kay-template   Author: yosukesuzuki   File: views.py    MIT License 5 votes vote down vote up
def send_reset_password_instruction(request, user_key, session_key):
  user = db.get(user_key)
  subject = render_to_string('auth/reset_password_instruction_subject.txt',
                             {'appname': settings.APP_NAME})
  message = render_to_string('auth/reset_password_instruction.txt',
                             {'appname': settings.APP_NAME,
                              'session_key': session_key})
  mail.send_mail(subject=subject, body=message,
                 sender=settings.DEFAULT_MAIL_FROM, to=user.email)
  return Response("OK") 
Example 28
Project: kay-template   Author: yosukesuzuki   File: views.py    MIT License 5 votes vote down vote up
def send_registration_confirm(request, registration_key):
  from kay.registration.models import RegistrationProfile
  import_string(settings.AUTH_USER_MODEL)
  p = db.get(registration_key)
  subject = render_to_string('registration/activation_email_subject.txt',
                             {'appname': settings.APP_NAME})
  subject = ''.join(subject.splitlines())
  message = render_to_string(
    'registration/activation_email.txt',
    {'activation_key': registration_key,
     'appname': settings.APP_NAME})
  mail.send_mail(subject=subject, body=message,
                 sender=settings.DEFAULT_MAIL_FROM, to=p.parent().email)
  return Response("OK") 
Example 29
Project: kay-template   Author: yosukesuzuki   File: mail.py    MIT License 5 votes vote down vote up
def mail_admins(subject, message, fail_silently=False):
  """Sends a message to the admins, as defined by the ADMINS setting."""

  sender_mail = settings.DEFAULT_MAIL_FROM
  if sender_mail == '[email protected]':
      sender_mail = None

  if not sender_mail and not settings.ADMINS:
    # If neither DEFAULT_MAIL_FROM and ADMINS are set
    # simply do nothing.
    return

  if (settings.DEBUG and not sender_mail and 
          (settings.ADMINS or settings.NOTIFY_ERRORS_TO_GAE_ADMINS)):
    # DEPRECATED 1.1
    # This code is deprecated and will be removed in
    # versions >= 1.5 or 2.0
    import logging
    logging.debug("Deprecation warning. Please set the DEFAULT_MAIL_FROM "
                 "setting in your settings.py. You will need to set the "
                 "DEFAULT_MAIL_FROM setting in order for error mails to "
                 "work properly in future versions of kay.")

  if settings.NOTIFY_ERRORS_TO_GAE_ADMINS:
    mail.send_mail_to_admins(sender=sender_mail or settings.ADMINS[0][1],
                             subject=subject,
                             body=message)

  for admin in settings.ADMINS:
    mail.send_mail(sender=sender_mail or admin[1],
                   to=admin[1],
                   subject=subject,
                   body=message) 
Example 30
Project: experts-app-backend   Author: GoogleDeveloperExperts   File: update_gplus.py    Apache License 2.0 5 votes vote down vote up
def send_update_mail(self, bad_posts, gplus_id):
        """Send out a mail with a link to the post for update."""

        # if we run this from the staging environment do not send emails
        app = app_identity.get_default_version_hostname()
        if app == "elite-firefly-737.appspot.com":
            logging.info('running from %s, not sending bad post email', app)
            return

        logging.info('sending a bad_post mail')

        # get the user
        accounts = Account.query(Account.gplus_id == gplus_id)

        for account in accounts:
            email = account.email

        body_s = "The Expert Tracking team thanks you for using the tool. \n\n"
        body_s += "The following post(s) is(are) missing Activity Type and/or Product Group hashtags. "
        body_s += "Because of this, it(they) does not reflect in your Expert stats. \n\n"

        for bad_post in bad_posts:
            body_s += "%s \n" % bad_post

        body_s += "\nKindly update your post(s) with #hashtags. A reminder of the valid "
        body_s += "hashtags can be found in the 'How Its Used?' section of http://gdetracking.gweb.io/. \n\n"
        body_s += "Expert Tracking Team"

        try:
            mail.send_mail(sender="Expert Tracking App Support <[email protected]>",
                           to=email,
                           subject="Expert Activity Tracker : Missing hashtags on ActivityPost for %s " % datetime.now(
                           ).strftime("%Y-%m-%d"),
                           body="""%s""" % body_s)
        except:
            logging.warning(
                "error sending email check user account %s", str(account.display_name)) 
Example 31
Project: AppEngineConferenceCenter   Author: lolitschen   File: main.py    Apache License 2.0 5 votes vote down vote up
def post(self):
        """Send email confirming Conference creation."""
        mail.send_mail(
            '[email protected]%s.appspotmail.com' % (
                app_identity.get_application_id()),     # from
            self.request.get('email'),                  # to
            'You created a new Conference!',            # subj
            'Hi, you have created a following '         # body
            'conference:\r\n\r\n%s' % self.request.get(
                'conferenceInfo')
        ) 
Example 32
Project: gae-smart-relay   Author: supernova2468   File: main.py    MIT License 5 votes vote down vote up
def post():

	# create entities
	new_log = Log()
	status = get_status()
	
	# fill data
	string_time = request.args.get('timestamp')
	new_log.timestamp = datetime.datetime.fromtimestamp(float(string_time)) - datetime.timedelta(hours=status.timezone)
	new_log.temperature = float(request.args.get('temperature'))
	new_log.current = float(request.args.get('current'))
	new_log.humidity = float(request.args.get('humidity'))
	new_log.battery_voltage = float(request.args.get('battery_voltage'))
	new_log.voltage = float(request.args.get('voltage'))
	new_log.frequency = float(request.args.get('frequency'))
	password = request.args.get('password')
	
	if request.args.get('state') == 'True':
		status.state = True
	else:
		status.state = False
		
	# save data
	if password == 'my_password':
		new_log.put()
		status.put()
		check = log_check(new_log)
		if check['check']:
			send_mail(check['value'], check['variable'])

	cutoff = get_cut()
	
	reply_string = '{},{},{},{},{},{},{},{},{},{},{},{},{}'
	return reply_string.format(status.command,
							cutoff.battery_voltage_l,cutoff.battery_voltage_h,
							cutoff.current_l,cutoff.current_h,
							cutoff.frequency_l,cutoff.frequency_h,
							cutoff.humidity_l,cutoff.humidity_h,
							cutoff.temperature_l,cutoff.temperature_h,
							cutoff.voltage_l,cutoff.voltage_h) 
Example 33
Project: gae-smart-relay   Author: supernova2468   File: main.py    MIT License 5 votes vote down vote up
def send_mail(value, variable):
	#check if one has already been sent today
	email_settings = get_email()
	if email_settings.last_mail == datetime.date.today():
		return
		
	sender_address = 'Smart Relay <[email protected]>'
	subject = 'Variable {} has gone out of range at {}'.format(variable,value)
    
	for user in registered_users:
		mail.send_mail(sender_address, user, subject, ' ')
	email_settings.last_mail = datetime.date.today()
	email_settings.put() 
Example 34
Project: tichu-tournament   Author: aragos   File: welcome_handler.py    MIT License 5 votes vote down vote up
def _SendEmails(self, request_dict, user, tourney):
    '''Sends a welcome email for all email addresses in the request_dict.

    Args: 
      request_dict: Parsed JSON dict.
      user: The ndb.User owning this tournament.
      tourney: The tournament model object. 
    ''' 
    player_pairs = PlayerPair._query(ancestor=tourney.key).fetch()
    requested_emails = request_dict["emails"]
    for player_pair in player_pairs:
      for player in player_pair.player_list():
        if player.get("email") not in requested_emails:
          continue
        player_name = player.get("name")
        player_greeting = "Dear {},".format(player_name) if player_name else "Greetings!"
        email_text = """{} 
\nWelcome to Tichu tournament \"{}\". Your pair's ID is {}.
You can use it to view and enter your results on https://tichu-tournament.appspot.com/home/{}. 
\nGood Luck!
Your friendly neighborhood tournament director""".format(
                player_greeting, tourney.name, player_pair.id, player_pair.id)
        email_html = """{}
<br/>
<br/>Welcome to Tichu tournament \"{}\". Your pair's ID is <b>{}</b>.
You can use it to view and enter your results on https://tichu-tournament.appspot.com/home/{}. 
<br/>
<br/>Good Luck!
<br/>Your friendly neighborhood tournament director
""".format(player_greeting, tourney.name, player_pair.id, player_pair.id)
        mail.send_mail(
            sender="{} <[email protected]{}.appspotmail.com>".format(tourney.name, get_application_id()),
            to=player["email"],
            subject="Your Tichu Tournament Pair Code",
            body=email_text,
            html=email_html,
            reply_to=user.email()) 
Example 35
Project: appengine-python-flask-travis-ci   Author: russomi   File: test_mail.py    Apache License 2.0 5 votes vote down vote up
def testMailSent(self):
    mail.send_mail(to='[email protected]',
                   subject='This is a test',
                   sender='[email protected]',
                   body='This is a test e-mail')
    messages = self.mail_stub.get_sent_messages(to='[email protected]')
    self.assertEqual(1, len(messages))
    self.assertEqual('[email protected]', messages[0].to)
# [END mail_example] 
Example 36
Project: Conference-Organization-APP-UDACITY   Author: kongling893   File: main.py    Apache License 2.0 5 votes vote down vote up
def post(self):
        """Send email confirming Conference creation."""
        mail.send_mail(
            '[email protected]%s.appspotmail.com' % (
                app_identity.get_application_id()),     # from
            self.request.get('email'),                  # to
            'You created a new Conference!',            # subj
            'Hi, you have created a following '         # body
            'conference:\r\n\r\n%s' % self.request.get(
                'conferenceInfo')
        ) 
Example 37
Project: Conference-Organization-APP-UDACITY   Author: kongling893   File: main.py    Apache License 2.0 5 votes vote down vote up
def post(self):
        """Send email confirming Conference creation."""
        mail.send_mail(
            '[email protected]%s.appspotmail.com' % (
                app_identity.get_application_id()),     # from
            self.request.get('email'),                  # to
            'You created a new Conference!',            # subj
            'Hi, you have created a following '         # body
            'conference:\r\n\r\n%s' % self.request.get(
                'conferenceInfo')
        ) 
Example 38
Project: Conference-Organization-APP-UDACITY   Author: kongling893   File: main.py    Apache License 2.0 5 votes vote down vote up
def post(self):
        """Send email confirming Conference creation."""
        mail.send_mail(
            '[email protected]%s.appspotmail.com' % (
                app_identity.get_application_id()),     # from
            self.request.get('email'),                  # to
            'You created a new Session!',            # subj
            'Hi, you have created a new Session in the following '         # body
            'conference:\r\n\r\n%s' % self.request.get(
                'conferenceInfo')
        ) 
Example 39
Project: seacat   Author: lmedina33   File: app_functions.py    GNU Affero General Public License v3.0 5 votes vote down vote up
def email(sender,to,subject='test',message='test',server='localhost:25',auth=None):
        """
        Sends an email. Returns True on success, False on failure.
        """
        if not isinstance(to,list): to=[to]
        try:
            try:
                from google.appengine.api import mail
                mail.send_mail(sender=sender,
                               to=to,
                               subject=subject,
                               body=message)
            except ImportError:
                msg="From: %s\r\nTo: %s\r\nSubject: %s\r\n\r\n%s"%(sender,\
                    ", ".join(to),subject,message)
                import smtplib, socket
                host, port=server.split(':')
                # possible bug fix? socket.setdefaulttimeout(None)
                server = smtplib.SMTP(host,port)
                #server.set_debuglevel(1)
                if auth:
                    server.ehlo()
                    server.starttls()
                    server.ehlo()
                    username, password=auth.split(':')
                    server.login(username, password)
                server.sendmail(sender, to, msg)
                server.quit()
        except Exception,e:
            return False 
Example 40
Project: python-docs-samples   Author: GoogleCloudPlatform   File: header.py    Apache License 2.0 5 votes vote down vote up
def send_example_mail(sender_address, email_thread_id):
    # [START send_mail]
    mail.send_mail(sender=sender_address,
                   to="Albert Johnson <[email protected]>",
                   subject="An example email",
                   body="""
The email references a given email thread id.

The example.com Team
""",
                   headers={"References": email_thread_id})
    # [END send_mail] 
Example 41
Project: python-docs-samples   Author: GoogleCloudPlatform   File: attachment.py    Apache License 2.0 5 votes vote down vote up
def post(self):
        f = self.request.POST['file']
        mail.send_mail(sender='{}@appspot.gserviceaccount.com'.format(
            app_identity.get_application_id()),
                       to="Albert Johnson <[email protected]>",
                       subject="The doc you requested",
                       body="""
Attached is the document file you requested.

The example.com Team
""",
                       attachments=[(f.filename, f.file.read())])
# [END send_attachment]
        self.response.content_type = 'text/plain'
        self.response.write('Sent {} to Albert.'.format(f.filename)) 
Example 42
Project: python-docs-samples   Author: GoogleCloudPlatform   File: mail_test.py    Apache License 2.0 5 votes vote down vote up
def testMailSent(self):
        mail.send_mail(to='[email protected]',
                       subject='This is a test',
                       sender='[email protected]',
                       body='This is a test e-mail')
        messages = self.mail_stub.get_sent_messages(to='[email protected]')
        self.assertEqual(1, len(messages))
        self.assertEqual('[email protected]', messages[0].to)
# [END mail_example] 
Example 43
Project: Conference_Central   Author: ananthashankar   File: main.py    Apache License 2.0 5 votes vote down vote up
def post(self):
        """Send email confirming Conference creation."""
        mail.send_mail(
            '[email protected]%s.appspotmail.com' % (
                app_identity.get_application_id()),     # from
            self.request.get('email'),                  # to
            'You created a new Conference!',            # subj
            'Hi, you have created a following '         # body
            'conference:\r\n\r\n%s' % self.request.get(
                'conferenceInfo')
        ) 
Example 44
Project: Conference_Central   Author: ananthashankar   File: main.py    Apache License 2.0 5 votes vote down vote up
def post(self):
        """Send email confirming Session creation."""
        mail.send_mail(
            '[email protected]%s.appspotmail.com' % (
                app_identity.get_application_id()),     # from
            self.request.get('email'),                  # to
            'You created a new Session!',            # subj
            'Hi, you have created a following '         # body
            'session:\r\n\r\n%s' % self.request.get(
                'sessionInfo')
        ) 
Example 45
Project: Authtopus   Author: rggibson   File: models.py    MIT License 5 votes vote down vote up
def send_email_verification( self, verification_url ):
        """ Sends a verificaiton email

        :param verification url:
            The URL the user must go to to verify their email
        :returns:
            True on success, False if too many verification emails have
            been sent
        """
        # Check for problems
        if not self.email_pending:
            logging.error( 'Unable to send email verification for user_id='
                           + str( self.get_id( ) ) + ' - no pending email' )
            return False
        
        # Create a verify email token
        token = self.create_verify_email_token( self.get_id( ),
                                                self.email_pending )
        if token is None:
            return False

        # Send mail
        sender = config.EMAIL_SENDER
        to = self.email_pending
        subject = config.EMAIL_VERIFY_SUBJECT
        body = config.EMAIL_VERIFY_BODY.format( self.username, (
            verification_url + '?token=' + token ) )

        mail.send_mail( sender, to, subject, body )
        logging.debug( 'Mail body:\n' + body )

        return True 
Example 46
Project: Authtopus   Author: rggibson   File: models.py    MIT License 5 votes vote down vote up
def send_password_reset_email( self, set_password_url ):
        """ Sends a password reset email

        :param set_password_url:
            The URL the user must go to to change their password
        :returns:
            ( True, None ) on success, ( False, msg ) on error
        """
        # Create password reset token
        token = self.create_password_reset_token( self.get_id( ) )
        if token is None:
            msg = ( "You currently have too many active password reset tokens."
                    + " You must wait for some tokens to expire before "
                    + "requesting a new token (tokens expire after "
                    + str( config.TOKEN_LIFE_HOURS.get( 'password_reset' ) )
                    + " hours)." )
            return False, msg
                    
        # Send mail
        sender = config.EMAIL_SENDER
        if self.email_verified:
            to = self.email_verified
        elif self.email_pending:
            to = self.email_pending
        else:
            return False, 'No email address found'
        subject = config.EMAIL_PASSWORD_RESET_SUBJECT
        body = config.EMAIL_PASSWORD_RESET_BODY.format( self.username, (
            set_password_url + '?user_id=' + str( self.get_id( ) )
            + '&token=' + token ) )

        mail.send_mail( sender, to, subject, body )
        logging.debug( 'Mail body:\n' + body )

        return True, None 
Example 47
Project: cron-gae   Author: LuciaSantos89   File: main.py    Apache License 2.0 5 votes vote down vote up
def get(self):
        #if self.request.headers.get('X-AppEngine-Cron'):
            today = datetime.today().replace(hour=00,minute=00,second=00,microsecond=0)
            notifications = NotifConfig.query(NotifConfig.notification_date == today)
            print notifications
            for n in notifications:
                mail.send_mail(sender="Lucia [email protected]",
                    to="[email protected]",
                    subject="Email notif",
                    body="Hoy es dia de notificacion!!!") 
Example 48
Project: python-compat-runtime   Author: GoogleCloudPlatform   File: report_generator.py    Apache License 2.0 5 votes vote down vote up
def __init__(self, *args, **kwargs):
    super(ReportGenerator, self).__init__(*args, **kwargs)


    self.send_mail = mail.send_mail
    self.send_mail_to_admins = mail.send_mail_to_admins 
Example 49
Project: crmint   Author: google   File: mailers.py    Apache License 2.0 5 votes vote down vote up
def finished_pipeline(self, pipeline):
    recipients = self.recipients(pipeline.recipients)
    if recipients:
      subject = "Pipeline %s %s." % (pipeline.name, pipeline.status)
      mail.send_mail(sender=self.SENDER,
                     to=recipients,
                     subject=subject,
                     body=subject)