コード例 #1
0
ファイル: mailer.py プロジェクト: avastjohn/maventy_old
def send_mail(subject, body, addresslist, 
              sender = settings.DEFAULT_FROM_EMAIL,
              doAppendSig=True, bcclist = None, reply_to = None):
  """ wrapper for Django's send_mail method """
  # Always prepend prefix to the subject
  subject = ''.join(subject.splitlines()) # *must not* contain newlines
  subject = "%s %s" % (settings.EMAIL_SUBJECT_PREFIX, subject)
  body = unicode(body) # may come in as a django.utils.safestring.SafeUnicode

  # Always include a signature
  if doAppendSig:
    body = "%s\n%s" % (body, settings.EMAIL_SIGNATURE)

  logging.debug("mailer.send_mail: addresslist %s bcclist %s body:\n%s" %
                (addresslist, bcclist, body))

  email = GoogleEmailMessage(subject  = subject, 
                             body     = body, 
                             sender   = sender,
                             to       = addresslist)
  if bcclist is not None and len(bcclist) > 0:
    email.bcc = bcclist
  if reply_to is not None:
    email.reply_to = reply_to

  from tasks import deliver_email_task
  # Note: For some reason synchronous works, asynchronous isn't working.
  # I'm not going to worry about that for now.
  # TODO(dan): Fix deferred.defer.
  deliver_email_task(email)
  #deferred.defer(deliver_email_task, email)

  # for testing, appengine patch keeps a list of mails
  if hasattr(mail, 'outbox') and not on_production_server:
    mail.outbox.append(email) #@UndefinedVariable (ignore py checker warnings)
コード例 #2
0
ファイル: emails.py プロジェクト: awolf/Foojal
def get_second_trial_communication_email(account):
    """ prepare the invitation email message """

    SUBJECT = "Foojal: Don't lose out."
    EMAIL_CONTENT = """

Hello %s

Just checking to see how you are liking your Foojal.com trial subscription.

Sign up today for a full year of Foojal.com for only $24.00 a year before we increase the price.
That's only $2.00 a month.

If you have any questions during your trial period, please email us; we would
love to talk with you.

Thank you, Kathy and Adam
%s"""

    message = EmailMessage()
    message.sender = settings.SITE_EMAIL
    message.to = account.user.email()
    message.subject = SUBJECT
    message.body = EMAIL_CONTENT % (account.nickname, settings.SITE_EMAIL)
    return message
コード例 #3
0
ファイル: user.py プロジェクト: wayne-abarquez/vizzuality
def login(base_url, login_return_url):
		
	user = users.get_current_user()

	# The user value object (VO) contains login and logout URLs.
	# (With /gateway stripped out so that it returns to the SWF). 
	
	urls = getUrls(base_url, login_return_url)
	
	user_vo = {
		'login': urls['login'],
		'logout': urls['logout'],
		'auth': False
	}
	
	if user:
		# Add the user object to the user VO.
		user_vo['user'] = user
		user_vo['auth'] = True
		
		# Get the user's profile from the database
		profile = UserProfile.all().filter('user ='******'profile'] = {
			'name': profile.name,
			'url': profile.url,
			'description': profile.description,
			'key': str(profile.key())
		}

		#logging.info('Profile name: %s' % profile.name)
		#logging.info('Profile url: %s' % profile.url)
		#logging.info('Profile description: %s' %profile.description)

	return user_vo
コード例 #4
0
ファイル: emailer.py プロジェクト: BarbaraEMac/TrivBot
    def send_email( from_addr, to_addr, subject, body ):

        if not is_good_email( from_addr ):
            logging.warning('send_email(): From address %s is malformed.' % from_addr )
        
        if not is_good_email( to_addr ):
            logging.warning('send_email(): To address %s is malformed.' % to_addr )

        e = EmailMessage(sender=from_addr, to=to_addr, subject=subject, html=body)
        e.send()
コード例 #5
0
ファイル: middleware.py プロジェクト: devsar/ae-people
    def process_exception(self, request, exception):
        logging.exception('exception!')
        message = EmailMessage()
        message.sender = settings.DEFAULT_FROM_EMAIL
        message.to = [admin[1] for admin in settings.ADMINS]
        message.subject = 'exception at %s' % request.path
        message.body = """
URL: %(url)s
Exception:
%(traceback)s

---

User: %(user)s 
Email: %(email)s

---

REQUEST META:
%(META)s
        """ % {
            'url': request.build_absolute_uri(request.get_full_path()),
            'traceback': traceback.format_exc(),
            'user': request.user,
            'email': request.user.email if request.user.is_authenticated() else None,
            'META': request.META
        }
        message.check_initialized()
        message.send()
        
        return None
コード例 #6
0
ファイル: mail.py プロジェクト: mixcloud/appengine-mailer
    def translate_message(self, msg):
        sender = msg.get_unixfrom() or msg['From']
        if not sender:
            if self.fix_sender:
                sender = self.default_sender
            else:
                raise BadMessageError("No sender specified")
        to = msg['To']
        if not to:
            raise BadMessageError("No destination addresses specified")
        message = EmailMessage(sender=sender or msg['From'], to=to)
        # Go through all the headers which Google will let us use
        cc = msg['Cc']
        if cc:
            message.cc = cc
        bcc = msg['Bcc']
        if bcc:
            message.bcc = cc
        reply_to = msg['Reply-To']
        if reply_to:
            message.reply_to = reply_to
        subject = msg['Subject']
        if subject:
            message.subject = subject

        # If there's just a plain text body, use that, otherwise
        # iterate over all the attachments
        payload = msg.get_payload(decode=True)
        if isinstance(payload, basestring):
            message.body = payload
        else:
            body = ''
            html = ''
            attachments = []
            # GAE demands we specify the body explicitly - we use the first text/plain attachment we find.
            # Similarly, we pull in the first html we find and use that for message.html
            # We pull in any other attachments we find; but we ignore the multipart structure,
            # because GAE doesn't give us enough control there.
            for part in msg.walk():
                if part.get_content_type() == 'text/plain' and not body:
                    body = part.get_payload(decode=True)
                elif part.get_content_type() == 'text/html' and not html:
                    html = part.get_payload(decode=True)
                elif not part.get_content_type().startswith('multipart'):
                    attachments.append(
                        (get_filename(part), part.get_payload(decode=True)))
            if not body:
                raise BadMessageError("No message body specified")
            message.body = body
            if html:
                message.html = html
            if attachments:
                message.attachments = attachments
        return message
コード例 #7
0
ファイル: models.py プロジェクト: BarbaraEMac/Side-Project
 def send_email(from_address, to_address, subject, body):
     try:
         e = EmailMessage(
                 sender=from_address, 
                 to=to_address, 
                 subject=subject, 
                 html=body
                 )
         e.send()
     except Exception,e:
         logging.error('error sending email: %s', e)
コード例 #8
0
ファイル: models.py プロジェクト: BarbaraEMac/Barbara-Mac
    def send( self ):
        # Add a check that it can only send on the date it's suppsoed to?
        
        e = EmailMessage( sender  = self.from_user.email(), 
                          to      = self.to_addr,
                          subject = self.subject, 
                          html    = self.body )
        e.send()

        self.sent = True
        self.put()
コード例 #9
0
ファイル: email.py プロジェクト: sharan1/love
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()
コード例 #10
0
ファイル: emailtemplate_views.py プロジェクト: prcek/TSReg
def test_send(request, et_id):
    et  = EMailTemplate.get_by_id(int(et_id))
    if et is None:
        raise Http404

    if request.method == 'POST':
        form = EMailTestForm(request.POST)
        if form.is_valid():
            try:
                email = EmailMessage(et.data)

                email.sender = cfg.getConfigString('ENROLL_EMAIL',None)
                email.reply_to = cfg.getConfigString('ENROLL_REPLY_TO',None)
                email.to = form.cleaned_data['email']
                email.check_initialized()

                logging.info('sending...')
                email.send()
                logging.info('send ok')

                et.valid = True 
                et.save()

            except:
                logging.info("can't init/send email! %s"%sys.exc_info()[1])
                return HttpResponse("can't init/send email - %s"%sys.exc_info()[1])


            return redirect('../..')
    else:
        form = EMailTestForm()
 
    return render_to_response('admin/emailtemplate_testsend.html', RequestContext(request, { 'form': form, 'et':et }) ) 
コード例 #11
0
ファイル: main.py プロジェクト: ikon42/reddit-unite
 def POST(self):
     d = web.input()
     t = template.env.get_template("message.html")
     sender = util.get_user(user_id=d.sender_id)
     recipient = util.get_user(user_id=d.recipient_id)
     message = EmailMessage(
         sender=" ".join([sender.nickname, "<" + (sender.user.email() or "*****@*****.**") + ">"]),
         subject=" ".join(["The Connection Machine:", sender.nickname, "wants to get in touch!"]),
         to=recipient.user.email(),
         reply_to=sender.user.email() or "*****@*****.**",
         body=t.render(msg=d.message, sender=sender.id or "us", site=web.ctx.homedomain, plain_text=True),
         html=t.render(msg=d.message, sender=sender.id or "us", site=web.ctx.homedomain),
     )
     message.send()
コード例 #12
0
def send_activation_email(user):
    '''Send the welcome email'''
    e = EmailMessage()
    e.subject = "Welcome to Parabay."
    e.body = """
    
    Hello,
    
    Thanks for signing up, please click the link below to download the Outlook plugin.
    
    %(url)s
    
    - Parabay team.
    
    """ % {
        'email':
        user.email,
        'url':
        '%s/%s' %
        ('http://parabayweb.appspot.com', 'app/ParabayOutlookSetup.msi')
    }

    e.sender = utils.SENDER_EMAIL
    e.to = user.email
    e.send()
コード例 #13
0
def send_mail(request):
    logging.info(request.POST)
    recipient = request.POST['recipient']
    ej_id = request.POST['ej_id']

    logging.info('fake email to %s'%(recipient)) 
    logging.info('ej_id %s'%ej_id)



    ej  = EMailJob.get_by_id(int(ej_id))
    if ej is None:
        return HttpResponse('missing ej')
 
    try:
        email = EmailMessage(ej.data)

        email.sender = cfg.getConfigString('ENROLL_EMAIL',None)
        email.reply_to = cfg.getConfigString('ENROLL_REPLY_TO',None)
        email.to = recipient
        email.check_initialized()

        logging.info('sending...')
        email.send()
        logging.info('send ok')
    except Exception,e:
        logging.info(e)
        logging.info("can't init/send email! %s"%sys.exc_info()[1])
        return HttpResponse("can't init/send email - %s"%sys.exc_info()[1])
コード例 #14
0
    def post(self):
        name = self.request.get('name')
        surname = self.request.get('surname')
        email = self.request.get('email')
        phone = self.request.get('phone')
        message = self.request.get('message')

        body = 'User %s,%s with email %s has sent you a message - %s' % (name,surname,email,message)

        my_mail = EmailMessage(sender='*****@*****.**',to='*****@*****.**',subject='Hi',body=body)

        #send email

        my_mail.check_initialized()
        my_mail.send()
コード例 #15
0
    def send_email(from_addr, to_addr, subject, body):

        if not is_good_email(from_addr):
            logging.warning('send_email(): From address %s is malformed.' %
                            from_addr)

        if not is_good_email(to_addr):
            logging.warning('send_email(): To address %s is malformed.' %
                            to_addr)

        e = EmailMessage(sender=from_addr,
                         to=to_addr,
                         subject=subject,
                         html=body)
        e.send()
コード例 #16
0
ファイル: mail.py プロジェクト: mixcloud/appengine-mailer
    def translate_message(self, msg):
        sender = msg.get_unixfrom() or msg["From"]
        if not sender:
            if self.fix_sender:
                sender = self.default_sender
            else:
                raise BadMessageError("No sender specified")
        to = msg["To"]
        if not to:
            raise BadMessageError("No destination addresses specified")
        message = EmailMessage(sender=sender or msg["From"], to=to)
        # Go through all the headers which Google will let us use
        cc = msg["Cc"]
        if cc:
            message.cc = cc
        bcc = msg["Bcc"]
        if bcc:
            message.bcc = cc
        reply_to = msg["Reply-To"]
        if reply_to:
            message.reply_to = reply_to
        subject = msg["Subject"]
        if subject:
            message.subject = subject

        # If there's just a plain text body, use that, otherwise
        # iterate over all the attachments
        payload = msg.get_payload(decode=True)
        if isinstance(payload, basestring):
            message.body = payload
        else:
            body = ""
            html = ""
            attachments = []
            # GAE demands we specify the body explicitly - we use the first text/plain attachment we find.
            # Similarly, we pull in the first html we find and use that for message.html
            # We pull in any other attachments we find; but we ignore the multipart structure,
            # because GAE doesn't give us enough control there.
            for part in msg.walk():
                if part.get_content_type() == "text/plain" and not body:
                    body = part.get_payload(decode=True)
                elif part.get_content_type() == "text/html" and not html:
                    html = part.get_payload(decode=True)
                elif not part.get_content_type().startswith("multipart"):
                    attachments.append((get_filename(part), part.get_payload(decode=True)))
            if not body:
                raise BadMessageError("No message body specified")
            message.body = body
            if html:
                message.html = html
            if attachments:
                message.attachments = attachments
        return message
コード例 #17
0
ファイル: report.py プロジェクト: srborines/esei-infra-ticket
    def get(self):
        today = dt.datetime.today()

        if (today.weekday() < 5 and today.month != 8):
            message_body = "Daily report\n\nPending open tickets\n\n===\n\n"
            tickets = Ticket.query(
                Ticket.status == Ticket.Status.Open).order(-Ticket.added)

            for ticket in tickets:
                message_body += str(ticket) + "\n\n---\n\n"

            message_body += "\n\n---\n\n" + AppInfo.AppWeb + "\n"

            EmailMessage(sender=AppInfo.AppEmail,
                         subject=AppInfo.Name + " report: " +
                         today.strftime("%Y-%m-%d %H:%M:%S"),
                         to=AppInfo.BroadcastEmail,
                         body=message_body.decode("ascii", "replace")).send()

            self.redirect("/info?url=/manage_tickets&msg=Report sent to: " +
                          AppInfo.BroadcastEmail.decode("ascii", "replace"))
        else:
            self.redirect(
                "/info?url=/manage_tickets&msg=Report only to be sent 9h mon-fri, except on august"
            )
コード例 #18
0
ファイル: models.py プロジェクト: benbest86/watsancomm
 def generate_reminder_email(cls):
     days = [
         'Monday',
         'Tuesday',
         'Wednesday',
         'Thursday',
         'Friday',
         'Saturday',
         'Sunday',
     ]
     day_map = dict(zip(range(7), days))
     plain_path = os.path.join(TEMPLATE_DIR, 'plain_text_reminder.txt')
     html_path = os.path.join(TEMPLATE_DIR, 'html_reminder.html')
     body = template.render(plain_path, {'deadline': day_map[CUTOFF_DAY]})
     html = template.render(html_path, {'deadline': day_map[CUTOFF_DAY]})
     sender = "*****@*****.**"
     bcc = cls.missing_updates()
     if not len(bcc):
         return None
     subject = "WatSan Weekly: Reminder Email"
     email = EmailMessage(
         body=body,
         html=html,
         sender=sender,
         bcc=bcc,
         subject=subject,
     )
     return email
コード例 #19
0
ファイル: views.py プロジェクト: prcek/VitalMenuTracker
def fire_email_subjob(request,subjob_key):

    if not getConfigBool('ENABLE_MAIL_JOBS',False):
        logging.info('ENABLE_MAIL_JOBS != True, ignore') 
        return HttpResponse('disabled')
        


    sub_job = EMailSubJob.get(subjob_key)
    if sub_job is None:
        logging.info('no sub_job')
        raise Http404

    job = EMailJob.get(sub_job.parent_key())
    if job is None:
        logging.info('no job')
        raise Http404


    job_data = EMailJobData.all().ancestor(job).get()
    if job_data is None:
        logging.info('no job_data')
        raise Http404

    try:
        email = EmailMessage(job_data.data)
        email.sender = job_data.sender
        email.to = job_data.sender
        email.check_initialized()
    except:
        logging.info("can't init email! %s"%sys.exc_info()[1])
        sub_job.status = 'error'
        sub_job.status_info = "can't init email message - %s"%sys.exc_info()[1]
        sub_job.save()
        return HttpResponse('error')



    logging.info('processing mail sub job:%s'%sub_job)
    sub_job.status = 'send'
    sub_job.save()

    for e in sub_job.emails:
        logging.info('sending email to %s'%e)
        try:
            email.to = e
            email.send() 
            sub_job.emails_done.extend([e])
        except:
            logging.info("can't init email! %s"%sys.exc_info()[1])
            sub_job.emails_error.extend([e])

    sub_job.status = 'done'
    sub_job.save()
    logging.info('result:%s'%sub_job)
    
    return HttpResponse('ok')
コード例 #20
0
ファイル: user.py プロジェクト: wayne-abarquez/vizzuality
def updateProfile(profileVO):
	user = users.get_current_user()
	
	if user:
		# Does the profile already exist?
		if profileVO.key == None:
			# No, create a new profile.
			profile = UserProfile()
			#logging.info("Creating a new profile!")
		else:
			# Yes, get the existing profile from the data store.
			profile = UserProfile.get(profileVO.key)
			#logging.debug("Updating existing profile...")
			
		# Update and save the profile.
		profile.user = user
		profile.name = profileVO.name
		profile.url = profileVO.url
		
		try:
			profile.description = profileVO.description
		except AttributeError:
			#logging.info("Profile description was empty, so we're skipping it.")
			pass

		profile.save()
		
		# Inform the user via email that they've updated their profile
		email = EmailMessage()
		email.subject = "Your shiny new profile."
		email.body = """
		Hello %(name)s,
		
		It's lovely to meet you. I've stored your profile safely in the bowels of the Googleplex.
		
		Name: %(name)s
		URL: %(url)s
		You are: %(description)s
		
		- The GAE SWF Robot (Alvin).""" % {'name': profile.name, 'url': profile.url, 'description': profile.description}
		email.sender = "*****@*****.**"
		email.to = user.email()
		email.send()
	
		return {'name': profile.name, 'url': profile.url, 'description': profile.description, 'key': profileVO.key}
	
	return False
コード例 #21
0
ファイル: mail.py プロジェクト: srborines/esei-infra-ticket
    def send_email(recipient, subject, body):
        subject = subject.encode("ascii", "replace")
        body = body.encode("ascii", "replace")

        EmailMessage(sender=AppInfo.AppEmail,
                     subject=subject,
                     to=recipient,
                     body=body).send()
コード例 #22
0
def sendMail(emailId, subject, body):
    emailMessage = EmailMessage()
    emailMessage.sender = "Support <*****@*****.**>"
    emailMessage.to = emailId
    emailMessage.subject = subject
    emailMessage.html = body
    return emailMessage.send()
コード例 #23
0
ファイル: emails.py プロジェクト: awolf/Foojal
def send_admin_notification(subject, data):
    message = EmailMessage()
    message.sender = settings.SITE_EMAIL
    message.to = settings.ADMIN_EMAIL
    message.subject = subject
    message.body = data
    message.send()
コード例 #24
0
ファイル: views.py プロジェクト: prcek/VitalMenuTracker
def email_template_test_send(request, template_id):
    et = EMailTemplate.get_by_id(int(template_id))
    if et  is None:
        raise Http404

    if request.method == 'POST':
        form = EMailAddressForm(request.POST)
        if form.is_valid():
            to_a = form.cleaned_data['address']
            logging.info('test send template id %d, to: %s', et.key().id(), to_a)
            
            try:
                email = EmailMessage(et.data)
                email.sender = getConfig('DEFAULT_SENDER')
                email.to = to_a
                email.check_initialized()

                if getConfigBool("ENABLE_MAIL_TEST",False):
                    logging.info('sending...')
                    email.send()
                else:
                    logging.info('disabled')
        

            except:
                logging.info("can't init email! %s"%sys.exc_info()[1])
                return HttpResponse("can't init email - %s"%sys.exc_info()[1])


            return redirect('..')
    else:
        form = EMailAddressForm()
 
    return render_to_response('emails/email_template_test_send.html', RequestContext(request, { 'form' : form, 'et':et}))
コード例 #25
0
 def make_mail_message(sender, to, subject, body):
     EMAIL_REGEX = re.compile(r"[^@]+@[^@]+\.[^@]+")
     email = None
     if EMAIL_REGEX.match(to):
         email = EmailMessage()
         email.sender = sender
         email.to = to
         email.subject = subject
         email.body = body
         email.check_initialized()
     return email
コード例 #26
0
ファイル: forms.py プロジェクト: mgoldfar/LSGConsultingWeb
    def send_mail(self):
        body="""
Full Name: %s
Email: %s
Phone: %s
Contact Method: %s

Message:
%s
""" % (self.fullname.data, self.email.data, self.phone.data,
               self.contactmethod.data, self.message.data )
        
        msg = EmailMessage(
            subject="Website Contact from %s" % self.fullname.data,
            to=settings.CONTACT_EMAIL_SEND_TO,
            sender=settings.CONTACT_EMAIL_SENDER,
            reply_to="%s" % self.email.data,
            body=body)
        msg.send()
コード例 #27
0
 def _gae_send(self, sender, to, subject, body, html):
     from google.appengine.api.mail import EmailMessage
     message = EmailMessage()
     message.sender = sender
     message.subject = subject
     message.body = body
     message.html = html
     message.to = to
     try:
         message.send()
     except Exception as ex:
         logging.warning(ex, exc_info=ex)
コード例 #28
0
ファイル: emails.py プロジェクト: awolf/Foojal
def get_invitation_email(address, key):
    """ prepare the invitation email message """

    EMAIL = "*****@*****.**"
    SUBJECT = "Your Foojal Invitation"
    URL = "http://app.foojal.com/invites/"
    EMAIL_CONTENT = """
You have been invited to Foojal.com!

To accept this invitation, click the following link,
or copy and paste the URL into your browser's address
bar:

%s"""

    message = EmailMessage()
    message.sender = EMAIL
    message.to = address
    message.subject = SUBJECT
    message.body = EMAIL_CONTENT % URL + key
    return message
コード例 #29
0
ファイル: emails.py プロジェクト: awolf/Foojal
def get_first_trial_communication_email(account):
    """ prepare the invitation email message """

    SUBJECT = "Foojal: First couple of days"
    EMAIL_CONTENT = """

Hello %s

Just checking to see how you are liking your first few days of Foojal.com.
If you have any questions during your trial period, please email us; we would
love to talk with you.

Your Team:
%s"""

    message = EmailMessage()
    message.sender = settings.SITE_EMAIL
    message.to = account.user.email()
    message.subject = SUBJECT
    message.body = EMAIL_CONTENT % (account.nickname, settings.SITE_EMAIL)
    return message
コード例 #30
0
def sendMail(emailId,subject,body):
    emailMessage = EmailMessage()
    emailMessage.sender = "Support <*****@*****.**>"
    emailMessage.to = emailId
    emailMessage.subject = subject
    emailMessage.html = body
    return emailMessage.send()
コード例 #31
0
ファイル: emails.py プロジェクト: awolf/Foojal
def get_last_trial_communication_email(account):
    """ prepare the invitation email message """

    SUBJECT = "Foojal: Your trial is over!"
    EMAIL_CONTENT = """

Hello %s

We hope you liked your Foojal.com trial and that you will join us for a full year for only $24.00.

To get a full year subscription to the best online photo food journal, go to your account page at http://app.foojal.com/account.

If you have any questions, please email us; we would love to talk with you.

Thank you, Kathy and Adam

"""
    message = EmailMessage()
    message.sender = settings.SITE_EMAIL
    message.to = account.user.email()
    message.subject = SUBJECT
    message.body = EMAIL_CONTENT % account.nickname
    return message
コード例 #32
0
ファイル: main.py プロジェクト: eve-val/evemail-bridge
  def get(self):
    config = memcache.get('config') or Configuration.all().get()
    if not config:
      # We haven't set up our configuration yet, so don't try to do anything
      return

    elink_api = elink_appengine.AppEngineAPI(api_key=(config.key_id, config.vcode))
    elink_char = evelink.char.Char(config.rcpt_char, api=elink_api)
    elink_eve = evelink.eve.EVE(api=elink_api)

    recips = set([config.rcpt_org])
    if config.rcpt_org2:
      recips.add(config.rcpt_org2)

    headers = elink_char.messages()
    message_ids = set(h['id'] for h in headers if h['to']['org_id'] in recips)

    headers = dict((h['id'], h) for h in headers)

    message_ids_to_relay = set()
    sender_ids = set()

    for m_id in message_ids:
      seen = memcache.get('seen-%s' % m_id) or SeenMail.gql("WHERE mail_id = :1", m_id).get()
      if not seen:
        message_ids_to_relay.add(m_id)
        sender_ids.add(headers[m_id]['sender_id'])
      else:
        memcache.set('seen-%s' % m_id, True)

    if not message_ids_to_relay:
      self.response.out.write("No pending messages.")
      return

    bodies = elink_char.message_bodies(message_ids_to_relay)
    senders = elink_eve.character_names_from_ids(sender_ids)

    e = EmailMessage()
    e.to = config.dest_email
    e.sender = '*****@*****.**'
    for m_id in message_ids_to_relay:
      sender = senders[headers[m_id]['sender_id']]
      timestamp = headers[m_id]['timestamp']
      e.subject = '[EVEMail] %s' % headers[m_id]['title']
      e.html = self.format_message(bodies[m_id] or '', timestamp, sender)
      e.send()
      SeenMail(mail_id=m_id).put()
      memcache.set('seen-%s' % m_id, True)
      self.response.out.write("Processed message ID %s.<br/>\n" % m_id)

    return
コード例 #33
0
ファイル: models.py プロジェクト: benbest86/watsancomm
 def generate_summary_email(cls, content):
     plain_path = os.path.join(TEMPLATE_DIR, 'plain_text_mail.txt')
     html_path = os.path.join(TEMPLATE_DIR, 'html_mail.html')
     body = template.render(plain_path, {'content': content})
     html = template.render(html_path, {'content': content})
     sender = "*****@*****.**"
     to = cls.recipients()
     subject = "WatSan Weekly Summary Email - %s" % date.today().strftime(
         "%d %b %Y")
     email = EmailMessage(
         body=body,
         html=html,
         sender=sender,
         to=to,
         subject=subject,
     )
     return email
コード例 #34
0
def send_account_deleted(user):
    '''Send the account deleted email'''
    e = EmailMessage()
    e.subject = "Parabay - Account Deleted"
    e.body = """
    
    Hello,
    
    Your account has been deleted.
        
    - Parabay team.
    
    """ % {
        'email': user.email
    }

    e.sender = utils.SENDER_EMAIL
    e.to = user.email
    e.send()
コード例 #35
0
ファイル: views.py プロジェクト: prcek/VitalMenuTracker
def parse_email(request, file_key):
    data = get_blob_data(file_key)
    if data is None:
        raise Http404

    r = ""
    email = EmailMessage(data)
#    fix_encoding(email)     
    email.check_initialized()
    email.sender = getConfig("MAIL_TEST_FROM")
    email.to = getConfig("MAIL_TEST_TO")

    if getConfigBool("ENABLE_MAIL_TEST",False):
        logging.info('sending email....')
        email.send()

    r = email.to_mime_message()

    return HttpResponse('parse ok - %s'%r)
コード例 #36
0
ファイル: ticket.py プロジェクト: Baltasarq/esei-infra-ticket
def send_email(rcpt, subject, body):
    subject = subject
    body = body

    logging.debug("Sending mail: '" + subject + "' to: " + rcpt)

    try:
        EmailMessage(sender=AppInfo.AppEmail,
                     subject=subject,
                     to=rcpt,
                     body=body).send()
        logging.debug("Email sent: '" + subject + "' to: " + rcpt)
    except OverQuotaError as e:
        logging.error("Quota error sending mail: '" + subject + "' to: " +
                      rcpt + "\n\t" + e.message)
    except Exception as e:
        logging.error("Unexpected error sending mail: '" + subject + "' to: " +
                      rcpt + "\n\t" + e.message)
コード例 #37
0
def send_password_reset(user, raw_password):
    '''Send the password reset email'''
    e = EmailMessage()
    e.subject = "Parabay - Password reset"
    e.body = """
    
    Hello,
    
    Your password has been reset to '%(password)s'.
        
    - Parabay team.
    
    """ % {
        'email': user.email,
        'password': raw_password
    }

    e.sender = utils.SENDER_EMAIL
    e.to = user.email
    e.send()
コード例 #38
0
ファイル: views.py プロジェクト: Laimiux/mydeatree
def contact_us(request):   
    if request.method == "POST":
        form = ContactForm(request.POST)
        if form.is_valid():
            cd = form.cleaned_data
            msg = EmailMessage()
            msg.sender = '*****@*****.**'
            msg.to = '*****@*****.**'
            msg.subject = cd['topic']
            msg.body = "From " + cd['name'] + " at " + cd['email'] + " Message: " + cd['message']
            #msg = "From " + cd['name'] + " at " + cd['email'] + " Message: " + cd['message']
            #send_mail(cd['topic'], msg, cd['email'], ['*****@*****.**'])
            msg.send()
            return HttpResponseRedirect('/contact/thanks/')
    else:
        form = ContactForm()       
    return render_to_response('contact_form.html', { 'form' : form }, context_instance=RequestContext(request))
コード例 #39
0
    def send_reference_email(self, ref_type):
        # disable automatic references until we are ready
        return

        if ref_type not in ['c', 'o']:
            raise ValueError

        if ref_type == 'c':
            to_email = self.HomeChurchEmail
        else:
            to_email = self.OtherReferenceEmail
        if not to_email:
            return

        message = EmailMessage()
        message.sender = "Housing Application <*****@*****.**>"
        message.to = to_email
        if self.House == "Men's Christian Campus House":
            message.subject = "CCH Housing Application Reference for {name}".format(name=self.FullName)
        else:
            message.subject = "WCCH Housing Application Reference for {name}".format(name=self.FullName)
        message.html = self._generate_reference_email_html(ref_type)
        message.body = self._generate_reference_email_text(ref_type)
        message.send()
コード例 #40
0
def send_account_deleted(user):
    '''Send the account deleted email'''
    e = EmailMessage()
    e.subject = "Parabay - Account Deleted"
    e.body = """
    
    Hello,
    
    Your account has been deleted.
        
    - Parabay team.
    
    """ % {'email': user.email}
    
    e.sender = utils.SENDER_EMAIL
    e.to = user.email
    e.send()
コード例 #41
0
def send_password_reset(user, raw_password):
    '''Send the password reset email'''
    e = EmailMessage()
    e.subject = "Parabay - Password reset"
    e.body = """
    
    Hello,
    
    Your password has been reset to '%(password)s'.
        
    - Parabay team.
    
    """ % {'email': user.email, 'password': raw_password}
    
    e.sender = utils.SENDER_EMAIL
    e.to = user.email
    e.send()
コード例 #42
0
def send_email(l):
    """Send an email notifying the recipient of l about their love."""
    sender_future = l.sender_key.get_async()
    recipient_future = l.recipient_key.get_async()

    # Remove this love from recent_love if present (datastore is funny sometimes)
    recent_love = recent_received_love(l.recipient_key, limit=4).get_result()
    index_to_remove = None
    for i, love in enumerate(recent_love):
        if l.sender_key == love.sender_key and l.recipient_key == love.recipient_key and l.message == love.message:
            index_to_remove = i
            break
    if index_to_remove is not None:
        del recent_love[index_to_remove]

    sender = sender_future.get_result()
    recipient = recipient_future.get_result()

    email = EmailMessage()
    email.sender = config.LOVE_SENDER_EMAIL
    email.to = recipient.user.email()
    email.subject = u'Love from {}'.format(sender.full_name)

    email.body = u'"{}"\n\n{}'.format(l.message,
                                      '(Sent secretly)' if l.secret else '')

    email.html = render_template('email.html',
                                 love=l,
                                 sender=sender,
                                 recipient=recipient,
                                 recent_love_and_lovers=[
                                     (love, love.sender_key.get())
                                     for love in recent_love[:3]
                                 ])

    email.send()
コード例 #43
0
ファイル: main.py プロジェクト: lizthegrey/evemail-bridge
  def send_notifications(self, config, elink_api, elink_char, elink_eve,
                         notify_descriptions):

    headers = elink_char.notifications()
    message_ids = set(headers[h]['id'] for h in headers
                      if headers[h]['type_id'] in config.notify_types )

    headers = dict((headers[h]['id'], headers[h]) for h in headers)

    message_ids_to_relay = set()
    sender_ids = set()

    for m_id in message_ids:
      seen = (memcache.get('nseen-%s' % m_id) or
              SeenNotification.gql("WHERE notify_id = :1", m_id).get())
      if not seen:
        message_ids_to_relay.add(m_id)
        sender_ids.add(headers[m_id]['sender_id'])
      else:
        memcache.set('nseen-%s' % m_id, True)

    if not message_ids_to_relay:
      self.response.out.write("No pending notifications.<br/>")
      return

    bodies = elink_char.notification_texts(message_ids_to_relay)
    senders = elink_eve.character_names_from_ids(sender_ids)

    e = EmailMessage()
    e.to = config.dest_email
    e.sender = '*****@*****.**'
    for m_id in message_ids_to_relay:
      sender = senders[headers[m_id]['sender_id']]
      timestamp = headers[m_id]['timestamp']
      e.subject = ('[EVE Notify] %s' %
          notify_descriptions.filter(
              "type_id = ", headers[m_id]['type_id']).get().description)
      e.html = self.format_notification(bodies[m_id], timestamp, sender,
                                        elink_eve)
      e.send()
      SeenNotification(notification_id=m_id).put()
      memcache.set('nseen-%s' % m_id, True)
      self.response.out.write("Processed notification ID %s.<br/>\n" % m_id)

    return
コード例 #44
0
    def get(self):
        time_delay = datetime.timedelta(
            days=self.settings.HousingApplication_ReminderEmailDelayDays)
        time_offset = datetime.datetime.utcnow() - time_delay
        unacknowledged_apps = HousingApplication.query(
            HousingApplication.Stage == 0,
            HousingApplication.TimeSubmitted < time_offset).fetch(20)

        message_html = self.generate_html(unacknowledged_apps)
        self.response.out.write(message_html)

        if len(unacknowledged_apps) > 0:
            message = EmailMessage()
            message.sender = "CCF Housing Application Reminder <*****@*****.**>"
            message.to = [
                self.settings.HousingApplicationCch_CompletionEmail,
                self.settings.HousingApplicationWcch_CompletionEmail
            ]
            message.subject = "CCF Housing Application Reminder ({date})".format(
                date=datetime.datetime.now(tz=Central).strftime('%b-%d-%Y'), )
            message.html = message_html
            message.send()
コード例 #45
0
ファイル: send.py プロジェクト: Algy/micro-blog
	def send(self):
		"""Método que envia email para destinatário."""
		email = EmailMessage()
		
		email.sender = '%s <%s>' % ("rlopes-blog", __email__)
		email.subject = 'Fale comigo - rlopes'
		email.to = __email__
		email.body = """
					Nome: %(nome)s
					Data Contato: %(data)s
					Email: %(email)s
					%(messagem)s
										
					""" % {'nome':self.nome.data, 
						   'data':datetime.today().strftime('%d/%m/%Y'),
						   'messagem':self.mensagem.data,
						   'email':self.email.data}
		
		email.send()
コード例 #46
0
    def get(self):
        errors = []
        end = time.time()
        start = end - (24 * 60 * 60)
        for log in logservice.fetch(
                start_time=start,
                end_time=end,
                include_app_logs=True,
                minimum_log_level=logservice.LOG_LEVEL_ERROR):
            for app_log in log.app_logs:
                if app_log.level >= 3:
                    errors.append(app_log.message.split('\n')[-1])

        self.response.out.write("There are %s errors.<br />" % len(errors))
        for e in errors:
            self.response.out.write(e + "<br />")

        if len(errors) > 0:
            message = EmailMessage()
            message.sender = "Rolla CCF Website Errors <*****@*****.**>"
            message.to = "*****@*****.**"
            message.subject = "CCF Website Errors (%s)" % len(errors)
            message.body = "\n".join(errors)
            message.send()
コード例 #47
0
ファイル: email.py プロジェクト: vladum/redirectioneaza
    def send_appengine_email(**kwargs):

        receiver = kwargs.get("receiver")
        sender = kwargs.get("sender", EmailManager.default_sender)
        subject = kwargs.get("subject")

        # email content
        text_template = kwargs.get("text_template")
        html_template = kwargs.get("html_template", "")

        # we must format the email address in this way
        receiver_address = "{0} <{1}>".format(receiver["name"],
                                              receiver["email"])
        sender_address = "{0} <{1}>".format(sender["name"], sender["email"])

        try:
            # create a new email object
            message = EmailMessage(sender=sender_address,
                                   to=receiver_address,
                                   subject=subject)

            # add the text body
            message.body = text_template

            if html_template:
                message.html = html_template

            if DEV:
                info(message.body)

            # send the email
            # on dev the email is not actually sent just logged in the terminal
            message.send()

            return True

        except Exception, e:
            warn(e)

            return False
コード例 #48
0
ファイル: utils.py プロジェクト: umitproject/tease-o-matic
def _gae_send_mail(sender, to, cc=None, bcc=None, reply_to=None, subject='', body='', html='', attachments=[], headers={}):
    email = EmailMessage()
    email.sender = sender
    email.to = to
    email.subject = subject
    email.body = body
    if cc: email.cc = cc
    if bcc: email.bcc = bcc
    if reply_to: email.reply_to = reply_to
    if html: email.html = html
    if attachments: email.attachments = attachments
    if headers: email.headers = headers
    
    return email.send()
コード例 #49
0
def send_mail_as_noreply(address,
                         subject,
                         msg=None,
                         html=None,
                         attachments=None):
    logging.info(u"Sending email to %s: [%s] %s" % (address, subject, msg))
    try:
        mail = EmailMessage()
        mail.sender = NO_REPLY_SENDER
        mail.to = address
        mail.subject = subject

        if attachments:
            mail.attachments = attachments

        if html:
            mail.html = html
        elif msg:
            mail.body = msg
        else:
            mail.body = "---"  # mail.body cannot be empty string, raises exception

        mail.check_initialized()
        mail.send()
    except Exception, e:
        logging.error("Email sending failed: %s" % e.message)
コード例 #50
0
ファイル: signup.py プロジェクト: Vishal5897/intern-contacts
def signup_email(email_to, subject, body):
    message = EmailMessage()
    message.sender = '*****@*****.**'
    message.to = [email_to]
    message.subject = subject
    message._add_body('text/html', body)
    message.check_initialized()
    message.send()
コード例 #51
0
ファイル: main.py プロジェクト: DrewB123/FAQMan
	id = ndb.IntegerProperty()

class User(ndb.Model):
	Fname = ndb.StringProperty()
	Lname = ndb.StringProperty()
	email = ndb.StringProperty()
	password = ndb.StringProperty()
	isInstructor = ndb.BooleanProperty()
	
	#get list of classes by calling user.classes
	classes = ndb.StringProperty(repeated=True)

# ##############################
# Email setup
JE = Environment(loader=FileSystemLoader('.'))
email_message = EmailMessage()

def redirect_to_main(response, message, duration):
    response.write(message)
    response.write('<meta http-equiv="refresh" content="' + str(duration) + ';url=/" />')
	
class Email(ndb.Model):
	from_address = ndb.StringProperty()
	to_addresses = ndb.StringProperty(repeated=True)
	subject      = ndb.StringProperty()
	body         = ndb.StringProperty()
	sent_date    = ndb.DateTimeProperty(auto_now=True)

	@staticmethod
	def get_email_from(urlsafe_key):
		return ndb.Key(urlsafe=urlsafe_key).get()