def send(self): params = { 'user': None, 'password': None, 'to': None, 'from': None, 'text': None, 'dlr-url': None, 'dlr-mask': None, 'coding': None} text = '' for key in params.keys(): text += "%s : %s \n" % (key, request.params.get(key, '-')) # simulate the delivery report import urllib2 url = request.params.get('dlr-url') url = url.replace('%d', '1') url = url.replace('%T', '1279709763.685117') urllib2.urlopen(url) send_email(sender=config.get('ututi_email_from', '*****@*****.**'), recipient=config.get('sms.dummy_send', '*****@*****.**'), subject='SMS dummy send', body=text) return '0;Message sent'
def _send_emails(user, post, group_id=None, category_id=None, controller=""): if group_id: forum_title = Group.get(group_id).title else: forum_title = _("Community") if category_id == 1 else _("Bugs") thread = ForumPost.get(post.thread_id) new_thread = thread.is_thread() extra_vars = dict( message=post.message, person_title=user.fullname, forum_title=forum_title, thread_url=url( controller=controller, action="thread", id=group_id, category_id=category_id, thread_id=post.thread_id, qualified=True, ), ) email_message = render("/emails/forum_message.mako", extra_vars=extra_vars) recipients = set() for subscription in thread.subscriptions: if subscription.active and subscription.user.id != user.id: for email in subscription.user.emails: if email.confirmed: recipients.add(email.email) break else: # Explicit unsubscription. for email in subscription.user.emails: try: recipients.remove(email.email) except KeyError: pass ml_id = group_id if not ml_id: ml_id = {1: _("ututi-community"), 2: _("ututi-bugs")}[int(category_id)] if recipients: re = "Re: " if not new_thread else "" send_email( config["ututi_email_from"], config["ututi_email_from"], "[%s] %s%s" % (ml_id, re, post.title), email_message, message_id=_generateMessageId(), send_to=list(recipients), )
def _flag(self, file): if request.method == 'POST': reason = request.POST.get('reason') if c.user: email = c.user.email.email else: email = request.POST.get('reporter_email') extra_vars = dict(f=file, reason=reason, email=email) send_email(config['ututi_email_from'], config['ututi_email_from'], 'Flagged file: %s' % file.filename, render('/emails/flagged_file.mako', extra_vars=extra_vars), send_to=[config['ututi_email_from']]) return htmlfill.render(render_mako_def('/sections/files.mako', 'flag_file', f=file))
def send_error(self): if request.method == 'POST': sender = config.get('ututi_emails_from', '*****@*****.**') action = request.POST.get('submit') user_shout = request.POST.get('error_message') message = "" if c.user: sender = c.user.email.email if action == "shout": h.flash(_('Monkeys are ashamed of what you said and are now working even harder to fix the problem. Until they do that, try to search for something else.')) message = user_shout elif action == "kick": message = '%s\n\n%s' % (_("User kicked monkeys"), user_shout) h.flash(_('Ouch! Monkeys were kicked and are trying to work harder. Until they fix this, try to search for something else.')) send_email(sender, config.get('error_email', '*****@*****.**'), "["+_("Error message")+"]", message) redirect(url(controller='search', action="index"))
def send(self, recipient): if recipient in self.ignored_recipients: return if hasattr(self, "subject") and hasattr(self, "text"): if isinstance(recipient, basestring): try: EmailValidator.to_python(recipient) recipient.encode('ascii') send_email(self.sender, recipient, self.subject, self.text, html_body=self.html, attachments=self.attachments) except (Invalid, UnicodeEncodeError): log.debug("Invalid email %(email)s" % dict(email=recipient)) else: Message.send(self, recipient=recipient) else: raise RuntimeError("The message must have a subject and a text to be sent.")