Ejemplo n.º 1
0
    def post(self, q):
        # takes input from user
        userMail = self.request.get("contact_email")
        name = self.request.get("contact_name")
        userMessage = self.request.get("contact_message")
        message = mail.EmailMessage(
            sender="goaweddingexpo.in: Contact Us<*****@*****.**>",
            subject="Contact")

        # not tested
        if not mail.is_email_valid(userMail):
            self.response.out.write("Wrong email! Check again!")

        message.to = userMail
        message.body = """Thank you!
	       You have entered following information:
	       Your mail: %s
	       Name: %s
	       Message: %s
         \nThank You For Contacting Goa Wedding Expo.""" % (userMail, name,
                                                            userMessage)
        message.send()
        # self.response.out.write("Message sent to user!")

        contact_message = mail.EmailMessage(sender="*****@*****.**",
                                            subject="Contact")
        contact_message.to = "*****@*****.**"
        contact_message.body = """The Following person contacted:
         Mail: %s
         Name: %s
         Message: %s""" % (userMail, name, userMessage)
        contact_message.send()
        # self.response.out.write("Message sent to goa wedding expo admin!")

        self.response.out.write("sent")
Ejemplo n.º 2
0
 def post(self):
     session = sessions.Session()
     ### Database entry ###
     user = User()
     user.email = self.request.get('email')
     user.city = str(self.request.get('city'))
     user.area = list(self.request.get_all('area'))
     user.put()
     ### Email to YDD ###
     session["Email"] = user.email
     message = mail.EmailMessage(
         sender="YourDinnerDeals <*****@*****.**>",
         subject="A User has Subscribed")
     message.to = "Vincent Jong <*****@*****.**>",
     message.body = session["Email"]
     message.send()
     ### Email to User ###
     template_values = {
         'email': session["Email"],
     }
     message = mail.EmailMessage(
         sender="YourDinnerDeals <*****@*****.**>",
         subject="Welcome to Your Dinner Deals")
     message.to = session["Email"],
     message.body = template.render('templates/confirm-email.html',
                                    template_values)
     message.html = template.render('templates/confirm-email.html',
                                    template_values)
     message.send()
     ### Redirect ###
     self.redirect('/thanks')
Ejemplo n.º 3
0
    def receive(self, mail_message):
        #Check that the subject contains a valid email address
        email_valid = validate_email(mail_message.subject)
        #If it does then proceed to assign the request
        if email_valid == True:
            #Make sure instructor is lower-case otherwise it is not assigned properly
            instructor = str(mail_message.subject)
            instructor = str.lower(instructor)
            #Generate a fake BlobKey to not upset GAE - this should be restructured in future
            blob_key = BlobKey("null")
            #Generate a horrible uuid index for the request
            requestId = str(uuid.uuid4())

            #Get the body from the email as plain text - this acts as our request desciption
            decodedBody = ''
            textBody = mail_message.bodies('text/plain')
            for content_type, body in textBody:
                decodedBody = body.decode()

            #Submit the request
            main.submit_form(requestId, str(mail_message.sender),
                             str(mail_message.sender), "other", instructor,
                             str(decodedBody), blob_key, "email")

            #Inform the instructor they have a new request
            instructorMessage = mail.EmailMessage(
                sender="MitCircs <*****@*****.**>",
                subject="MitCircs - New Submission")
            instructorMessage.to = instructor
            instructorMessage.html = """<h1 style='text-align: center'>MitCircs - New Request</h1>
            <br> <p style='text-align: center'> You have recieved a new request from:
            <br> <b>""" + str(mail_message.sender) + """</b>
            <br> <br> Request ID:
            <br> <br> <b>""" + requestId + """</b>
            <br> <br> To view this submission, please login to <a href='https://mitcircs.robtaylor.info'>MitCircs</a> and click on "manage requests".
            <br> <br> Thanks,
            <br> The MitCircs Team </p>"""
            instructorMessage.send()
        #The subject doesn't contain a valid email - inform the student of this and don't assign the request
        else:
            studentMessage = mail.EmailMessage(
                sender="MitCircs <*****@*****.**>",
                subject="MitCircs - Submission Error")
            studentMessage.to = mail_message.sender
            studentMessage.html = """<h1 style='text-align: center'>MitCircs - Submission Error</h1>
            <br> <p style='text-align: center'> Your email submission has not been logged. Please ensure you include your instructor's email in the subjext line.
            <br> <br> Thanks,
            <br> The MitCircs Team</p>"""
            studentMessage.send()
Ejemplo n.º 4
0
def forgot(request):
    if not request.REQUEST.has_key("email"):
        return direct_to_template(request, "forgotlogin.html")
    hunters = db.GqlQuery("SELECT * FROM AptHunter WHERE email = :1",
                          request.REQUEST["email"])
    if hunters.count(1) < 1:
        return direct_to_template(
            request,
            "forgotlogin.html",
            extra_context={"email": request.REQUEST["email"]})
    hunter = hunters[0]
    msg = mail.EmailMessage(
        sender=settings.FROM_EMAIL,
        to=hunter.email,
        subject="Homesearchr login reset",
        bcc=settings.ADMINS[0][1],
    )
    # it should be easy enough to predict this reset cookie
    h = hashlib.sha1()
    h.update(hunter.username)
    h.update(str(datetime.datetime.now()))
    h.update(settings.SECRET_KEY)
    resetcookie = h.hexdigest() + "reset"
    hunter.sessioncookie = resetcookie
    db.put(hunter)
    msg.body = "Please use an HTML compatible email program to see this."
    msg.html = '<a href="http://homesearchr.com/users/reset?reset=%s">Click here to reset your homesearcher login</a>' % resetcookie
    msg.send()
    return direct_to_template(request,
                              "forgotlogin-success.html",
                              extra_context={"email": hunter.email})
Ejemplo n.º 5
0
def send_invite_email(email):
    student = RoseboticsStudent.get_by_id(email)
    if student is None:
        return
    if mail.is_email_valid(student.alt_email):
        email = [email, student.alt_email]
    message = mail.EmailMessage(
        sender="*****@*****.**")
    message.to = email
    message.subject = "ROSEbotics Team Invite"
    message.body = """ 
Hello,

You've been invited to join a ROSEbotics Team! Teams is a place where you can create study groups and monitor others progress within the courses on the website. 
    
You can see your pending invites at: http://www.rosebotics.org/teams/#/invites/

Happy Learning!

-- The ROSEbotics Team
     """.strip()
    try:
        message.send()
        logging.info("Invite Email should have been sent to: " + str(email))
    except Exception, e:
        logging.warn("Invite Email not sent to: " + str(email) + str(e))
Ejemplo n.º 6
0
 def _copy_message(self, message):
     """Create and return App Engine EmailMessage class from message."""
     gmsg = aeemail.EmailMessage(sender=message.from_email,
                                 to=message.to,
                                 subject=message.subject,
                                 body=message.body)
     if message.extra_headers.get('Reply-To', None):
         gmsg.reply_to = message.extra_headers['Reply-To']
     if message.bcc:
         gmsg.bcc = list(message.bcc)
     if message.attachments:
         # Must be populated with (filename, filecontents) tuples
         attachments = []
         for attachment in message.attachments:
             if isinstance(attachment, MIMEBase):
                 attachments.append((attachment.get_filename(),
                                     attachment.get_payload(decode=True)))
             else:
                 attachments.append((attachment[0], attachment[1]))
         gmsg.attachments = attachments
     # Look for HTML alternative content
     if isinstance(message, EmailMultiAlternatives):
         for content, mimetype in message.alternatives:
             if mimetype == 'text/html':
                 gmsg.html = content
                 break
     return gmsg
Ejemplo n.º 7
0
def send_emails(request):
    num_emails = 0
    if 'pid' not in request.GET:
        players = Player.objects.all()
        urls = []
        for player in players:
            url = '/tournament/send_emails/?pid=%s' % player.pk
            taskqueue.add(url=url, method='GET')
            urls.append(url)
        return HttpResponse("Queued:\n%s" % urls)
    really = True
    player = Player.objects.get(pk=request.GET['pid'])
    to_email = '*****@*****.**'
    cc = ['*****@*****.**']
    if really:
        to_email = player.user.email
        cc.extend(('*****@*****.**', '*****@*****.**'))
    message_body = render_to_string('tournament/begin_email.txt',
                                    {'player': player})
    message = mail.EmailMessage(
        sender="Table Tennis Tournament <*****@*****.**>",
        to=to_email,
        cc=cc,
        subject='Table Tennis Tournament Begins!',
        body=message_body)
    message.send()
    num_emails += 1
    return HttpResponse("sent %d emails" % num_emails)
Ejemplo n.º 8
0
def _Send(recipients, subject, body, sender, reply_to, bcc_recipients):
    """Private function to send mail message with AppEngine mail API.

  Args:
    recipients: list, str email addresses to send the email to.
    subject: str, email subject.
    body: str, email body.
    sender: str, optional, email address to send the email from; defaults to
        settings.DEFAULT_EMAIL_SENDER.
    reply_to: str, optional, email address to set the Reply-To header; defaults
        to settings.DEFAULT_EMAIL_REPLY_TO.
    bcc_recipients: list, optional, str email addresses to BCC.
  """
    try:
        message = mail.EmailMessage(to=recipients,
                                    sender=sender
                                    or settings.DEFAULT_EMAIL_SENDER,
                                    subject=subject,
                                    body=body)
        if reply_to or settings.DEFAULT_EMAIL_REPLY_TO:
            message.reply_to = reply_to or settings.DEFAULT_EMAIL_REPLY_TO
    except mail.InvalidEmailError:
        logging.warning('Email settings are incorrectly configured; skipping')
        return

    if bcc_recipients:
        message.bcc = bcc_recipients

    message.send()
Ejemplo n.º 9
0
    def post(self):
        message = mail.InboundEmailMessage(self.request.body)
        ## Get the traderID from the post based on the email address and "forward" the email
        this_post = Post.query(
            Post.contact == message.to).order(-Post.engage).get()
        email_to = this_post.traderID

        if mail.is_email_valid(email_to):
            email_messages = message.bodies('text/plain')
            email = get_email_text("Post Reply")

            for content_type, msg in email_messages:
                full_message = mail.EmailMessage(
                    sender="%s <%s@%s>" %
                    (bitsettings.site_name, bitsettings.email_local,
                     bitsettings.email_suffix),
                    subject="%s %s - %s" %
                    (bitsettings.email_subject, this_post.title,
                     str(this_post.price)),
                    to="%s <%s>" % (email_to.split('@')[0], email_to),
                    reply_to=message.sender,
                    body=email.find('header').text + "\n\n" +
                    str(message.subject).upper() + "\n" + msg.decode() +
                    "\n\n" + email.find('footer').text,
                )
                full_message.send()
Ejemplo n.º 10
0
    def register_code_sent(self, *args):
        if args[0]:
            aiesec_email = args[0]
            random_number = randint(10000, 99999)

            member = self.current_member()
            member.temp_email_code = aiesec_email + ";" + str(random_number)
            message = mail.EmailMessage(
                sender="I am an AIESECer <*****@*****.**>",
                subject="Verification code")
            message.to = "{0} <{1}>".format(member.name, aiesec_email)
            message.body = """
            Dear {0}:
            
            This is the verification code for your account:
            
                           {1}
            
            Please enter this code in the application to verify your account.
            
            I am an AIESECer Team
            """.format(member.first_name, random_number)

            message.send()
            member.save()
            return self.render(r'register/code_sent',
                               {'aiesec_email': aiesec_email})
        else:
            return self.render(r'register/code_request',
                               {'message': 'Invalid email.'})
Ejemplo n.º 11
0
def send_status_update_email(recipient, cnumber, prevstatus, currstatus,
                             email2):
    message = mail.EmailMessage(
        sender="case monitoring <*****@*****.**>",
        subject="Status of your case %s  changed." % cnumber)

    message.to = recipient.email()
    if email2:
        message.cc = email2
    message.body = """
        Dear %s:

        Status of your case %s have been changed from %s to %s.
        Please check it out on
           http://case-monitoring.appspot.com
        or
           https://egov.uscis.gov/cris/Dashboard/CaseStatus.do

        Thanks,
        """ % (
        recipient.nickname(),
        cnumber,
        prevstatus,
        currstatus,
    )
    message.send()
    logging.info("send status update to email: %s, %s" %
                 (message.to, message.body))
Ejemplo n.º 12
0
    def post(self):
        try:
            name = self.request.get('name').strip()
            email = self.request.get('email').strip()
            subject = self.request.get('subject').strip()
            content = self.request.get('content').strip()

            if (not name) or (not email) or (not subject) or (not content):
                raise Exception('No fields can be empty.')

            message = mail.EmailMessage()
            message.sender = '*****@*****.**'
            message.to = '*****@*****.**'
            message.subject = subject
            message.body = 'An email send from '+name+' ('+email+').\n\n'+ content
            message.send()

            context = {
                'message': 'Thank you very much. I\'ve received your message. :)',
                'error': False,
            }
            self.render('sent', context)
        except Exception, e:
            context = {
                'message': str(e),
                'error': True,
            }
            self.render('sent', context)
Ejemplo n.º 13
0
    def invite_user(self, email):
        """
        Invite user to join Takanash with email

        :param email: invited user's email
        :return: UserModel(new user)
        """
        # clear up input value
        email = email.lower()

        user = db.GqlQuery('select * from UserModel where email = :1 limit 1',
                           email)
        if user.count(1) > 0:
            # user is exist
            return UserModel().get(user[0].key())

        # add a new user
        user = UserModel()
        user.email = email
        user.name = email
        user.put()

        # send a invite email
        message = mail.EmailMessage(
            sender=config.gae_account,
            subject="%s has invited you to join Victory." % g.user.name)
        message.to = email
        message.body = 'Victory https://%s\n\nAccount: %s' % (config.domain,
                                                              email)
        message.send()

        user.get(user.key())  #sync
        return user
Ejemplo n.º 14
0
    def handle(self):
        """Handles the creation of user accounts.

        Attempts to create a new user account with the specified username, password, email, and 
        phone number. Fails creating a new user if the username or email is taken. If user creation 
        does not fail, the user will be sent a verification email to confirm their account.
        """
        username = self.getParam(Keys.USERNAME)
        email = self.getParam(Keys.EMAIL)
        phone = self.getParam(Keys.PHONE_NUMBER)
        first_name = self.getParam(Keys.FIRST_NAME)
        last_name = self.getParam(Keys.LAST_NAME)

        # Check if the username or email has been taken by a verified user or a user that still is
        # attempting to verify their email.
        user_entries = User.query(User.username == username).fetch()
        if len(user_entries) != 0:
            return {Keys.SUCCESS: 0, Keys.ERROR_MESSAGE: "Username taken"}

        user_entries = User.query(User.email == email).fetch()
        if len(user_entries) != 0:
            return {
                Keys.SUCCESS: 0,
                Keys.ERROR_MESSAGE: "Email already in use"
            }

        # Remove all non-numbers from the phone number
        phone = re.sub("[^0-9]", "", phone)

        # Create a new unverified user and put the user in the database
        user = User(username=username,
                    email=email,
                    phone=phone,
                    verified=False,
                    first_name=first_name,
                    last_name=last_name,
                    current_meetup=None)
        user.put()

        #
        link = user.get_create_link(VERIFICATION_TIME_MINUTES)

        # Generate a verification email for the new user
        email_body_template = get_template('res/user_verification_email.html')
        email_body = email_body_template.render({
            'confirmation_link':
            link.link,
            'username':
            user.username,
            'minutes':
            VERIFICATION_TIME_MINUTES,
        })

        # Send the verification email to the user
        mail.EmailMessage(sender=AUTHORIZED_EMAIL,
                          to=email,
                          subject='Confirm Your Registration',
                          html=email_body).send()

        return {Keys.SUCCESS: 1, Keys.DEVICE_KEY: link.device_code}
Ejemplo n.º 15
0
    def handle(self):
        email = self.getParam(Keys.EMAIL)

        user_entries = [u for u in User.query(User.email == email).fetch()]

        if len(user_entries) == 0:
            return {Keys.SUCCESS: 1, Keys.DEVICE_KEY: 999999}

        user = user_entries[0]
        link = user.get_login_link(VERIFICATION_TIME_MINUTES)

        # Generate a verification email for the new user
        email_body_template = get_template('res/user_login_email.html')
        email_body = email_body_template.render({
            'confirmation_link': link.link,
            'device_code': link.device_code,
            'username': user.username,
        })

        print(link.link)

        # Send the verification email to the user
        mail.EmailMessage(sender=AUTHORIZED_EMAIL,
                          to=email,
                          subject='Log In To Your Account',
                          html=email_body).send()

        return {
            Keys.SUCCESS: 1,
            Keys.DEVICE_KEY: link.device_code,
        }
Ejemplo n.º 16
0
    def get(self):
        weekday = datetime.today().weekday()
        if (weekday <
                5):  #This control limits blocks the emails on Sat and Sun
            # These code snippets use an open-source library. http://unirest.io/python

            response = unirest.get(
                "https://webknox-jokes.p.mashape.com/jokes/oneLiner",
                headers={
                    "X-Mashape-Key":
                    "CC9qExPz1xmshMlClnCaQArQh3nip1PTsqYjsnP2aOar9pQfTx"
                })
            joke = response.body['text']
            #joke = "na"

            currentHour = int(datetime.now().strftime('%H')) + 1  #e.g. 9
            # Compse the message
            message = mail.EmailMessage(
                sender="Visual Learning Pulse <*****@*****.**>",  #"",
                subject="It's time to rate your activity")
            message.html = "<!DOCTYPE html><html><body style='font-family: Arial, sans-serif; font-size:11px; text-align:center;'> \
                <p>" + joke + "</p><br /><p>Please remember to submit your ratings.</p><br />  \
                Visual Learning Pulse - Welten Institute 2016</p></body></html>"

            # Loop through the email array Participants and send an email
            for email in participants:
                message.to = email
                message.send()
Ejemplo n.º 17
0
    def post(self):
        upload_files = self.get_uploads('file')
        blob_info = upload_files[0]
        uploader = self.request.get('uploader', default_value='')
        note = self.request.get('note', default_value='')
        f = File(blob_key=blob_info.key(),
                 note=note,
                 uploader=uploader,
                 filename=blob_info.filename,
                 size=blob_info.size)
        f.put()
        message = mail.EmailMessage(
            sender="Personal File Sharing Service <%s>" % EMAIL,
            subject="Shared file from %s" % uploader)

        message.to = "Xiangru Chen <%s>" % EMAIL
        message.body = '''
        Dear Xiangru,

        You have a shared file uploaded by %s.

        Notes with the file:

        %s

        You can download this file at the following address:

        %s

        Best Regards.
        ''' % (uploader, note, f.serve_url())

        message.send()
        self.redirect('/thanks/')
Ejemplo n.º 18
0
    def post(self):
        Guser = users.get_current_user()
        AppEmail = '*****@*****.**'
        if Guser:
            vstrToEmail = self.request.get('vstrToEmail')
            vstrSubject = self.request.get('vstrSubject')
            vstrcomposetextarea = self.request.get('vstrcomposetextarea')
            vstrMessageIndex = self.request.get('vstrMessageIndex')
            vstrMessageIndex = int(vstrMessageIndex)
            message = mail.EmailMessage()
            message.sender = AppEmail
            message.to = vstrToEmail
            message.subject = vstrSubject
            message.html = vstrcomposetextarea

            message.send()
            findRequest = Contact.query(
                Contact.strMessageIndex == vstrMessageIndex)
            thisContactList = findRequest.fetch()
            if len(thisContactList) > 0:
                thisContact = thisContactList[0]
                thisContact.strResponded = True
                thisContact.put()

                self.response.write("Response Successfully sent to recipient")
Ejemplo n.º 19
0
def SendEmail(recipients, subject, body, sender=None, reply_to=None,
              bcc_recipients=None):
  """Sends a mail message with the AppEngine mail API.

  Args:
    recipients: list, str email addresses to send the email to.
    subject: str, email subject.
    body: str, email body.
    sender: str, optional, email address to send the email from; defaults to
        settings.DEFAULT_EMAIL_SENDER.
    reply_to: str, optional, email address to set the Reply-To header; defaults
        to settings.DEFAULT_EMAIL_REPLY_TO.
    bcc_recipients: list, optional, str email addresses to BCC.
  """
  if settings.DEVELOPMENT:
    logging.warn('Not sending email in development mode')
    logging.info(
        'Would have sent email to %s:\nSubject: %s\nBody:\n\n%s',
        recipients, subject, body)
  else:
    message = mail.EmailMessage(
        to=recipients,
        reply_to=reply_to or settings.DEFAULT_EMAIL_REPLY_TO,
        sender=sender or settings.DEFAULT_EMAIL_SENDER,
        subject=subject,
        body=body)
    if bcc_recipients:
      message.bcc_recipients = bcc_recipients
    message.send()
Ejemplo n.º 20
0
def getNewBus(stopcode):
    """
    Sends a new e-mail to carris requesting information about a bus stop.

    Returns false if an error occurs, true otherwise.
    """
    message = mail.EmailMessage(sender="Lx Bus <%s>" % APP_MAIL,
                            subject=CARRIS_SUBJECT_SPEC+stopcode)
    message.to = CARRIS_MAIL
    
    requestid = genRequestId(stopcode)
    
    nrequest = BusRequest(requestid=requestid, created_date=datetime.today(), stopcode=stopcode, status_code=BUSREQUEST_REQUESTED)
    
    nrequest.put()
    
    message.body= requestid

    try:
        message.send()
    except:
        logging.exception("Error ocurred while trying to send email to carris.")
        return None
    
    return requestid
Ejemplo n.º 21
0
def send_adj_status_update_email(recipient, cnumber, changelist, email2):

    message = mail.EmailMessage(
        sender="case monitoring <*****@*****.**>",
        subject="Some adjacent cases status changed (your case: %s)." %
        cnumber)

    message.to = recipient.email()
    if email2:
        message.cc = email2
    message.body = """
        Dear %s:

        Based on your case number: %s, following adjacent cases have been changed
%s
        Please check it out on
           http://case-monitoring.appspot.com
        or
           https://egov.uscis.gov/cris/Dashboard/CaseStatus.do

        Thanks,
        """ % (recipient.nickname(), cnumber, "\n".join([
        "%s, %s -> %s" % (cn, prevs, currs) for cn, prevs, currs in changelist
    ]))
    message.send()
    logging.info("send adj status update to email: %s, %s" %
                 (message.to, message.body))
Ejemplo n.º 22
0
def email_admin(details):
    sender = "EURYPAA 2016 Admin <*****@*****.**>"
    subject = "New Registration on EURYPAA 2016: %s" % details['first_name']
    message = mail.EmailMessage(sender=sender, subject=subject)
            
    message.to = "EURYPAA 2016 Admin <*****@*****.**>"
    
    message.body = """
    Dear Admin:
    
    There has been a new registration on EURYPAA 2016:

    first_name: %(first_name)s,
    last_name: %(last_name)s,
    registration_type: %(registration_type)s,
    mobile: %(mobile)s,
    email: %(email)s,
    country: %(country)s,
    sobriety_date: %(sobriety_date)s,
    ypaa_committee: %(ypaa_committee)s,
    fellowship: %(fellowship)s,
    special_needs: %(special_needs)s,
    of_service: %(of_service)s

    Stay awesome.
    """ % details
    
    message.send()
Ejemplo n.º 23
0
    def post(self):

        ac_kod = str(uuid.uuid4())
        passw = x = md5.new(cgi.escape(
            self.request.get('password'))).hexdigest()
        user = User(name=cgi.escape(self.request.get('firstname')),
                    mail=cgi.escape(self.request.get('mail')),
                    password=passw,
                    activ_key=ac_kod,
                    activ=False)
        user.put()

        message = mail.EmailMessage(sender="Alo box <*****@*****.**>",
                                    subject="Hesap Aktivasyonu")
        message.to = '<' + user.mail + '>'

        message.body = MAIL_STR.format(user.name, self.request.host_url,
                                       user.activ_key)
        message.html = MAIL_STR.format(user.name, self.request.host_url,
                                       user.activ_key)
        message.send()

        self.response.out.write(
            'Hesabınız oluşturulmuştur. Activasyon için E-Posta Gelen Kutunuzu kontrol ediniz'
        )
Ejemplo n.º 24
0
def send_contact_email(details):
    sender = "EURYPAA 2016 user <*****@*****.**>"
    subject = "EURYPAA 2016 Contact form, Subject: %(subject)s" % details
    message = mail.EmailMessage(sender=sender, subject=subject)
    message.to = "EURYPAA 2016 Admin <*****@*****.**>"
    message.body = ("\nNAME: %(name)s,\nEMAIL: %(email)s\n" + details['message']) % details
    message.send()
Ejemplo n.º 25
0
	def send_mail(self, msg, msubject, email):
		message = mail.EmailMessage(sender="CoLabs Support {0}".format(config['mailers']['emails']),
                            subject=msubject)
		message.to = str(email)
		message.body = str(msg)
		message.html = str(msg)
		message.send()
Ejemplo n.º 26
0
  def post(self, key):
      """Worker that runs in the 'background'"""
      if settings.DEBUG is not True:
      # If not in debug mode, then really send emails
      # Get the object from the database
        email = models.Email.get(key)

        # Construct a appengine.api.mail object
        message = mail.EmailMessage()
        message.sender = email.sender
        message.to = email.to
        if email.cc:
          message.cc = email.cc
        message.bcc = settings.ADMINS
        message.subject = email.subject
        # message.reply_to = email.sender
        if email.reference:
          message.headers = {
              "References": email.reference # Make threading works in Gmail
          } 
        logging.info("Message sent to: %s" % message.to)

        # Set text and html body
        message.html = email.html

        # Send. Important: Sometimes emails fail to send, which will throw an
        # exception and end the function there. Next round tries again.
        message.send()

        # Now the message was sent and we can safely delete it.
        email.delete()
Ejemplo n.º 27
0
def email_missing_stop(stopID, routeID, sid):
    # setup the response email
    message = mail.EmailMessage()
    message.sender = config.EMAIL_SENDER_ADDRESS
    message.to = config.EMAIL_REPORT_ADDRESS
    message.subject = 'Missing stop ID requested by API client - %s' % stopID
    message.body = 'RouteID: %s \n' % routeID + 'SID: %s \n' % sid
Ejemplo n.º 28
0
    def get(self):
        users = db.GqlQuery("SELECT * FROM UserPass")
        for user in users:
            userid = str(user.user_id)
            if (user.preferences == 'on'):
                quotes = UserQuotes.gql("Where user = :1", userid)
                quote_list = list(quotes)
                if quote_list:
                    leng = len(quote_list)
                    r = random.randrange(leng)
                    quote = quote_list[r]
                    str0 = '<html> <head></head> <body>'
                    str1 = ' <table cellpadding="0" cellspacing="0" border="0">	<tbody><tr>	<td> <table cellpadding="0" cellspacing="0" border="0" align="center"> <tbody><tr> <td width="600" valign="top"><h3><span style="color:#888888">%s</span></h3> <p><span style="color:#999999">' % (
                        quote.content.encode('utf-8'))
                    str2 = '%s</span></p><br><br><hr></td> </tr></tbody></table></td></tr></tbody></table> ' % str(
                        quote.whosaid)
                    str3 = '</body></html>'
                    msg_content = str0 + str1 + str2 + str3
                    message = mail.EmailMessage(
                        sender="Amir Hesam Salavati <*****@*****.**>",
                        subject="Daily Digest of Personal Quotes")
                    message.to = "%s" % str(user.user_email)
                    message.html = """%s""" % msg_content

                    message.send()
                else:
                    self.response.out.write('Sorry!<br>')
Ejemplo n.º 29
0
def site_check(user_id):
    account = Account.get_by_id(user_id)
    failed_site_reports = []
    for site in account.sites:
        if site:
            result = urlfetch.fetch(site)
            if result.status_code != 200:
                failed_site_reports.append(
                    "site {} failed with a {} status code".format(
                        site, result.status_code))
    if failed_site_reports:
        failed_site_report = '\n'.join(failed_site_reports)
        message = mail.EmailMessage()
        message.sender = 'failures@[email protected]'
        message.body = """Failures for your site on {}:
        {}
        """.format('downtime-toy.appspot.com', failed_site_report)
        message.subject = "Notification of site failures"
        message.to = account.email
        try:
            message.send()
            logging.info("sent email to {} for failed sites.".format(
                account.email))
        except:
            logging.warn(
                "failed to send owner email to {} for failed sites.".format(
                    account.email))
    else:
        logging.info("no failed sites for email {}".format(account.email))
Ejemplo n.º 30
0
		def post(self):
			name = self.request.get('name')
			phone = self.request.get('phone')
			email = self.request.get('email')
			message = self.request.get('message')

			if phone == "":
				mail_message = mail.EmailMessage(sender="*****@*****.**", subject="%s at <%s> emailed you from atterholtfordistrictjudge.com!" % (name, email))
			else:
				mail_message = mail.EmailMessage(sender="*****@*****.**", subject="%s at <%s (%s)> emailed you from atterholtfordistrictjudge.com!" % (name, email, phone))
			
			mail_message.to = "Mark Atterholt<*****@*****.**>"
			mail_message.body = message
			mail_message.send()

			self.response.out.write('Success');