Example #1
0
 def testGetApplicationNoReplyEmail(self):
   """Tests that a correct no-reply email is returned.
   """
   if self.default_application_id is None:
     let_current_app_id = 'test-app-run'
     try:
       os.environ['APPLICATION_ID'] = let_current_app_id
       expected = "no-reply@%s.appspotmail.com" % let_current_app_id
       self.assertEqual(system.getApplicationNoReplyEmail(), expected)
     finally:
       del os.environ['APPILICATION_ID']
   else:
     current_app_id = os.environ['APPLICATION_ID']
     expected = "no-reply@%s.appspotmail.com" % current_app_id
     self.assertEqual(system.getApplicationNoReplyEmail(), expected)
Example #2
0
def getMailContext(to, subject, html, sender=None, bcc=None):
  """Constructs a mail context for the specified arguments.
  """
  if not sender:
    sender = system.getApplicationNoReplyEmail()

  context = {
      'subject': subject,
      'html': html,
      'sender': sender,
  }

  if to:
    context['to'] = to

  if bcc:
    context['bcc'] = bcc

  return context
Example #3
0
def request_account_deletion(user):
  """Requests deletion of user's account from application administrators
  by sending them an email.
  
  This is a temporary method, until we have an automated solution.
  """
  account = accounts.getCurrentAccount(normalize=False)
  sender = system.getApplicationNoReplyEmail()

  subject = ADMIN_REQUEST_EMAIL_SUBJEST % {
      'link_id': user.link_id
      }
  body = ADMIN_REQUEST_EMAIL_BODY % {
      'name': user.name,
      'email': account.email(),
      'link_id': user.link_id
      }

  mail.send_mail_to_admins(sender, subject, body)
Example #4
0
def getDefaultMailSender(data=None):
    """Returns the sender that currently can be used to send emails.

  Args:
    data: an option RequestData object

  Returns:
    - A tuple containing (sender_name, sender_address)
    Consisting of:
  """
    from soc.logic import system
    from soc.logic import site

    # check if there is a noreply email address set

    if data:
        site_entity = data.site
    else:
        site_entity = site.singleton()

    no_reply_email = system.getApplicationNoReplyEmail()

    return (site_entity.site_name, no_reply_email)