def do_email_students(self): log.debug(str(request.params)) user = h.get_user(request.environ) student_ids_str = request.params['student_ids'] student_ids = ah.fileset_id_string_to_id_list(student_ids_str) students = Student.query.filter(Student.id.in_(student_ids)).all() students = filter(lambda student: request.params.has_key(str(student.id)), students) for student in students: check_student_access(student) subject = request.params['subject'] body = request.params['body'] from_addr = (user.givenName+" "+user.surName,user.name + '@illinois.edu') reply_to = user.name + '@illinois.edu' to_addrs = map(lambda student: (student.displayName, student.netid + "@illinois.edu"), students) from turbomail import Message message = Message() message.subject = subject message.plain = body message.author = from_addr message.reply_to = reply_to message.to = to_addrs message.cc = from_addr message.send() if request.params.has_key('assignment_id'): return redirect_to(controller='view_analysis', action='view', id=request.params['assignment_id']) else: return redirect_to(controller='view_analysis', action='list')
def send_email(sender, truename, emails, title, plain, rich): """ notify using email sending alert email to followers """ """ rand send email """ day_str = datetime.datetime.strftime(datetime.datetime.today(),"%d%H") sender = 'Knowing <*****@*****.**>' % day_str logging.debug('Send email %s' % ', '.join((truename, str(emails), title, plain, rich))) try: mail = Message() mail.subject = title mail.sender = sender mail.to = u'%s <%s>' % (truename, emails[0]) if len(emails) > 1: mail.cc = u','.join(emails[1:]) mail.encoding = 'utf-8' mail.plain = plain mail.rich = rich mail.send() except Exception, e: logging.exception('Fail to send email.')
def send_email(sender, truename, emails, title, plain, rich): """ notify using email sending alert email to followers """ """ rand send email """ day_str = datetime.datetime.strftime(datetime.datetime.today(), "%d%H") sender = "Knowing <*****@*****.**>" % day_str logging.debug("Send email %s" % ", ".join((truename, str(emails), title, plain, rich))) try: mail = Message() mail.subject = title mail.sender = sender mail.to = u"%s <%s>" % (truename, emails[0]) if len(emails) > 1: mail.cc = u",".join(emails[1:]) mail.encoding = "utf-8" mail.plain = plain mail.rich = rich mail.send() except Exception, e: logging.exception("Fail to send email.")
def send_email(self, imgs1, imgs2): day_str = datetime.datetime.strftime(datetime.datetime.today(), "%Y-%m-%d") mail = Message() mail.subject = u'#%s#SOS日报' % day_str mail.sender = '*****@*****.**' #mail.to = self.config['sos_receiver'] self.owner.append('*****@*****.**') self.owner.append('*****@*****.**') self.owner.append('*****@*****.**') self.owner.append('*****@*****.**') self.owner.append('*****@*****.**') self.owner.append('*****@*****.**') mailto = list(set(self.owner)) mail.to = ','.join(mailto) mail.encoding = 'utf-8' mail.plain = u'本邮件由Knowing系统自动发送,如有疑问请联系运维团队,谢谢。' title_style = 'font-size: 15px; font-weight: bold; padding-top: 10px;' items = [ u'<p>Hi All,</p><p>本邮件由Knowing系统自动发送,实时数据可<a href="http://knowing.corp.126.com/monitor/341">点此查看</a>,如有疑问请联系运维团队,谢谢。</p>' ] for img in imgs1: items.append( u'<div style="%s">%s</div><p><img src="cid:%d.png"></p>' % (title_style, img[1], img[0])) mail.embed(img[2], u'%d.png' % img[0]) items.append( '<table border="0" cellspacing="0" cellpadding="0" width="1024">') for i in xrange(0, len(imgs2), 2): items.append( u'<tr><td><div style="%s">%s</div><img src="cid:%d.png"></td>' % (title_style, imgs2[i][1], imgs2[i][0])) mail.embed(imgs2[i][2], u'%d.png' % imgs2[i][0]) if i + 1 < len(imgs2): items.append( u'<td valign="bottom"><div style="%s">%s</div><img src="cid:%d.png"></td></tr>' % (title_style, imgs2[i + 1][1], imgs2[i + 1][0])) mail.embed(imgs2[i + 1][2], u'%d.png' % imgs2[i + 1][0]) else: items.append(u'<td> </td></tr>') items.append('</table>') mail.rich = u''.join(items) print 'Sending email...' mail.send()
def send_email(self, imgs1, imgs2): day_str = datetime.datetime.strftime(datetime.datetime.today(),"%Y-%m-%d") mail = Message() mail.subject = u'#%s#SOS日报' % day_str mail.sender = '*****@*****.**' #mail.to = self.config['sos_receiver'] self.owner.append('*****@*****.**') self.owner.append('*****@*****.**') self.owner.append('*****@*****.**') self.owner.append('*****@*****.**') self.owner.append('*****@*****.**') self.owner.append('*****@*****.**') mailto = list(set(self.owner)) mail.to = ','.join(mailto) mail.encoding = 'utf-8' mail.plain = u'本邮件由Knowing系统自动发送,如有疑问请联系运维团队,谢谢。' title_style = 'font-size: 15px; font-weight: bold; padding-top: 10px;' items = [u'<p>Hi All,</p><p>本邮件由Knowing系统自动发送,实时数据可<a href="http://knowing.corp.126.com/monitor/341">点此查看</a>,如有疑问请联系运维团队,谢谢。</p>'] for img in imgs1: items.append(u'<div style="%s">%s</div><p><img src="cid:%d.png"></p>' % (title_style, img[1], img[0])) mail.embed(img[2], u'%d.png' % img[0]) items.append('<table border="0" cellspacing="0" cellpadding="0" width="1024">') for i in xrange(0, len(imgs2), 2): items.append(u'<tr><td><div style="%s">%s</div><img src="cid:%d.png"></td>' % (title_style, imgs2[i][1], imgs2[i][0])) mail.embed(imgs2[i][2], u'%d.png' % imgs2[i][0]) if i + 1 < len(imgs2): items.append(u'<td valign="bottom"><div style="%s">%s</div><img src="cid:%d.png"></td></tr>' % (title_style, imgs2[i+1][1], imgs2[i+1][0])) mail.embed(imgs2[i+1][2], u'%d.png' % imgs2[i+1][0]) else: items.append(u'<td> </td></tr>') items.append('</table>') mail.rich = u''.join(items) print 'Sending email...' mail.send()
def do_email_students_ajax(self): log.debug(str(request.params)) user = h.get_user(request.environ) student_ids_str = request.params['student_ids'] student_ids = ah.fileset_id_string_to_id_list(student_ids_str) students = Student.query.filter(Student.id.in_(student_ids)).all() students = filter(lambda student: request.params.has_key(str(student.id)), students) for student in students: check_student_access(student) subject = request.params['subject'] body = request.params['body'] from_addr = (user.givenName+" "+user.surName,user.name + '@illinois.edu') reply_to = user.name + '@illinois.edu' to_addrs = map(lambda student: (student.displayName, student.netid + "@illinois.edu"), students) from turbomail import Message message = Message() message.subject = subject message.plain = body message.author = from_addr message.reply_to = reply_to message.to = to_addrs message.cc = from_addr message.send() return "Message Sent Successfully"