Ejemplo n.º 1
0
def subscribe(message, group_name=None, host=None):

	group = None
	group_name = group_name.lower()
	name, addr = parseaddr(message['from'].lower())

	try:
		user = UserProfile.objects.get(email=addr)
		group = Group.objects.get(name=group_name)

	except UserProfile.DoesNotExist:
		error_msg = 'Your email is not in the Murmur system. Ask the admin of the group to add you.'
		send_error_email(group_name, error_msg, addr, ADMIN_EMAILS)
		return

	except Group.DoesNotExist:
		error_msg = 'The group' + group_name + 'does not exist.'
		send_error_email(group_name, error_msg, addr, ADMIN_EMAILS)
		return

	if not group.public:
		error_msg = 'The group ' + group_name + ' is private. Ask the admin of the group to add you.'
		send_error_email(group_name, error_msg, addr, ADMIN_EMAILS)
		return

	res = subscribe_group(group_name, user)
	subject = "Subscribe -- Success"
	body = "You are now subscribed to: %s@%s" %(group_name, host)

	if(not res['status']):
		subject = "Subscribe -- Error"
		body = "Error Message: %s" %(res['code'])

	mail = MailResponse(From = NO_REPLY, To = message['From'], Subject = subject, Body = body) 
	relay.deliver(mail)
Ejemplo n.º 2
0
def info(message, group_name=None, host=None):

    # for now I'm not sure what we would have here, 
    # but we can change this later on.
    if WEBSITE == 'squadbox':
        logging.debug("No group info sent via email in Squadbox")
        return

    elif WEBSITE == 'murmur':
        group_name = group_name.lower()
        res = group_info(group_name)
        subject = "Group Info -- Success"
        body = "Group info for %s:\n" %(group_name)
        if(res['status']):
            body = "Group Name: %s@%s, Active: %s\n\n" %(res['group_name'], host, res['active'])
            for member in res['members']:           
                body += "%s : %s\n" %('Email: ', member['email'])
                body += "%s : %s\n" %('Active: ', member['active'])
                body += "%s : %s\n" %('Member: ', member['member'])
                body += "%s : %s\n" %('Guest: ', member['guest'])
                body += "%s : %s\n" %('Moderator: ', member['moderator'])
                body += "%s : %s\n" %('Admin: ', member['admin'])
            body += "\n..........................\n"       
        else:
            subject = "Group Info -- Error"
            body = "Error Message: %s" %(res['code'])
            
        mail = MailResponse(From = NO_REPLY, To = message['From'], Subject = subject, Body = body)
        relay.deliver(mail)
Ejemplo n.º 3
0
def POSTING(message, post_name=None, host=None, action=None):
    name, address = parseaddr(message['from'])

    if not action:
        post.post(post_name, address, host, message)
        msg = view.respond(locals(), 'mail/page_ready.msg',
                           From="noreply@%(host)s",
                           To=message['from'],
                           Subject="Your page '%(post_name)s' is ready.")
        relay.deliver(msg)

        # first real message, now we can index it
        index_q = queue.Queue("run/posts")
        index_q.push(message)
    elif action == "delete":
        post.delete(post_name, address)

        msg = view.respond(locals(), 'mail/deleted.msg',
                           From="noreply@%(host)s",
                           To=message['from'],
                           Subject="Your page '%(post_name)s' was deleted.")

        relay.deliver(msg)
    else:
        logging.debug("Invalid action: %r", action)

    return POSTING
Ejemplo n.º 4
0
def unsubscribe(message, group_name=None, host=None):

	group = None
	group_name = group_name.lower()
	name, addr = parseaddr(message['from'].lower())

	try:
		user = UserProfile.objects.get(email=addr)

	except UserProfile.DoesNotExist:
		error_msg = 'Your email is not in the Murmur system. Ask the admin of the group to add you.'
		send_error_email(group_name, error_msg, addr, ADMIN_EMAILS)
		return

	res = unsubscribe_group(group_name, user)
	subject = "Unsubscribe -- Success"
	body = "You are now unsubscribed from: %s@%s." %(group_name, host)
	body += " To resubscribe, reply to this email."

	if(not res['status']):
		subject = "Unsubscribe -- Error"
		body = "Error Message: %s" %(res['code'])

	mail = MailResponse(From = NO_REPLY, To = message['From'], Subject = subject, Body = body)
	mail['Reply-To'] = '%s+subscribe@%s' %(group_name, host)
	relay.deliver(mail)
Ejemplo n.º 5
0
def BOUNCING(message, address=None, host=None):
    msg = view.respond(locals(), 'mail/we_have_disabled_you.msg',
                       From='*****@*****.**',
                       To=message['from'],
                       Subject='You have bounced and are disabled.')
    relay.deliver(msg)
    return BOUNCING
Ejemplo n.º 6
0
def START(message, list_name=None, host=None, bad_list=None):
    if bad_list:
        if '-' in bad_list:
            # probably put a '.' in it, try to find a similar list
            similar_lists = mailinglist.similar_named_lists(bad_list.replace('-','.'))
        else:
            similar_lists = mailinglist.similar_named_lists(bad_list)

        help = view.respond(locals(), "mail/bad_list_name.msg",
                            From="noreply@%(host)s",
                            To=message['from'],
                            Subject="That's not a valid list name.")
        relay.deliver(help)

        return START

    elif list_name in INVALID_LISTS or message['from'].endswith(host):
        logging.debug("LOOP MESSAGE to %r from %r.", message['to'],
                     message['from'])
        return START

    elif mailinglist.find_list(list_name):
        action = "subscribe to"
        CONFIRM.send(relay, list_name, message, 'mail/confirmation.msg',
                          locals())
        return CONFIRMING_SUBSCRIBE

    else:
        similar_lists = mailinglist.similar_named_lists(list_name)
        CONFIRM.send(relay, list_name, message, 'mail/create_confirmation.msg',
                          locals())

        return CONFIRMING_SUBSCRIBE
Ejemplo n.º 7
0
def help(message, address=None, host=None):

    if WEBSITE == 'squadbox':
        # we should change this to actually send a useful help email
        # with the possible via-email commands in squadbox
        return

    elif WEBSITE == 'murmur':
        to_addr = message['From']
        from_addr = address + '@' + HOST
        subject = "Help"
        body = "Welcome to %s. Please find below a general help on managing a group mailing list.\n\n" %(host)
        body += "To create a new group: <name>+create@%s\n" %(host)
        body += "To activate/re-activate your group: <name>+activate@%s\n" %(host)
        body += "To de-activate your group: <name>+deactivate@%s\n" %(host)
        body += "To subscribe to a group: <name>+subscribe@%s\n" %(host)
        body += "To unsubscribe from a group: <name>+unsubscribe@%s\n" %(host)
        body += "To see details of a group: <name>+info@%s\n" %(host)
        body += "To see a listing of all the groups: all@%s\n" %(host)
        body += "To get help: help@%s\n" %(host)
        body += "To post message to a group: <name>@%s\n\n" %(host)
        body += "Please substitute '<name>' with your group name."  
        mail = MailResponse(From = from_addr, To = to_addr, Subject = subject, Body = body)
        relay.deliver(mail)
        return
Ejemplo n.º 8
0
def help(message, address=None, host=None):

    if WEBSITE == 'squadbox':
        # we should change this to actually send a useful help email
        # with the possible via-email commands in squadbox
        return

    elif WEBSITE == 'murmur':
        to_addr = message['From']
        from_addr = address + '@' + HOST
        subject = "Help"
        body = "Welcome to %s. Please find below a general help on managing a group mailing list.\n\n" % (
            host)
        body += "To create a new group: <name>+create@%s\n" % (host)
        body += "To activate/re-activate your group: <name>+activate@%s\n" % (
            host)
        body += "To de-activate your group: <name>+deactivate@%s\n" % (host)
        body += "To subscribe to a group: <name>+subscribe@%s\n" % (host)
        body += "To unsubscribe from a group: <name>+unsubscribe@%s\n" % (host)
        body += "To see details of a group: <name>+info@%s\n" % (host)
        body += "To see a listing of all the groups: all@%s\n" % (host)
        body += "To get help: help@%s\n" % (host)
        body += "To post message to a group: <name>@%s\n\n" % (host)
        body += "Please substitute '<name>' with your group name."
        mail = MailResponse(From=from_addr,
                            To=to_addr,
                            Subject=subject,
                            Body=body)
        relay.deliver(mail)
        return
Ejemplo n.º 9
0
Archivo: admin.py Proyecto: wRAR/lamson
def START(message, list_name=None, host=None, bad_list=None):
    if bad_list:
        if '-' in bad_list:
            # probably put a '.' in it, try to find a similar list
            similar_lists = mailinglist.similar_named_lists(
                bad_list.replace('-', '.'))
        else:
            similar_lists = mailinglist.similar_named_lists(bad_list)

        help = view.respond(locals(),
                            "mail/bad_list_name.msg",
                            From="noreply@%(host)s",
                            To=message['from'],
                            Subject="That's not a valid list name.")
        relay.deliver(help)

        return START

    elif list_name in INVALID_LISTS or message['from'].endswith(host):
        logging.debug("LOOP MESSAGE to %r from %r.", message['to'],
                      message['from'])
        return START

    elif mailinglist.find_list(list_name):
        action = "subscribe to"
        CONFIRM.send(relay, list_name, message, 'mail/confirmation.msg',
                     locals())
        return CONFIRMING_SUBSCRIBE

    else:
        similar_lists = mailinglist.similar_named_lists(list_name)
        CONFIRM.send(relay, list_name, message, 'mail/create_confirmation.msg',
                     locals())

        return CONFIRMING_SUBSCRIBE
Ejemplo n.º 10
0
def handle_post(message, address=None, host=None):
	address = address.lower()
	name, addr = parseaddr(message['From'].lower())
	reserved = filter(lambda x: address.endswith(x), RESERVED)
	if(reserved):
		return
	group_name = address.lower()
	subject = '[ %s ] -- %s' %(group_name, message['Subject'].encode('ascii', 'ignore'))
	msg_text = get_body(str(message))
	res = insert_post(group_name, subject, msg_text['body'], addr)
	if(not res['status']):
		mail = MailResponse(From = NO_REPLY, To = addr, Subject = "Error", Body = "Error Message:%s" %(res['code']))
		relay.deliver(mail)
		return
	msg_id = res['msg_id']
	thread_id = res['thread_id']
	to_send =  res['recipients']
	post_addr = '%s <%s>' %(group_name, group_name + '+' + str(thread_id) + '+' + str(msg_id) + POST_SUFFIX + '@' + host)
	mail = MailResponse(From = message['From'], To = post_addr, Subject  = subject)
	
		
	if 'references' in message:
		mail['References'] = message['References']
	elif 'message-id' in message:
		mail['References'] = message['message-id']	
	
	
	mail['message-id'] = msg_id

	ps_blurb = html_ps(thread_id, msg_id, group_name, host)
	mail.Html = unicode(msg_text['body'] + ps_blurb , "utf-8")		
	logging.debug('TO LIST: ' + str(to_send))
	if(len(to_send)>0):
		relay.deliver(mail, To = to_send)
Ejemplo n.º 11
0
def handle_reply(message, group_name=None, thread_id=None, msg_id=None, suffix=None, host=None):
	name, addr = parseaddr(message['from'].lower())
	msg_id = msg_id.lower()
	group_name = group_name.lower()
	msg_text = get_body(str(message))
	res = insert_reply(group_name, message['Subject'], msg_text['body'], addr, msg_id, thread_id)
	if(not res['status']):
		mail = MailResponse(From = NO_REPLY, To = addr, Subject = "Error", Body = "Error Message:%s" %(res['code']))
		relay.deliver(mail)
		return
	msg_id = res['msg_id']
	to_send =  res['recipients']
	post_addr = '%s <%s>' %(group_name, group_name + '+' + str(thread_id) + '+' + str(msg_id) + POST_SUFFIX + '@' + host)
	mail = MailResponse(From = message['From'], To = post_addr, Subject = message['Subject'])
	
	if 'references' in message:
		mail['References'] = message['References']
	elif 'message-id' in message:
		mail['References'] = message['message-id']

	
	mail['message-id'] = msg_id
	
	ps_blurb = html_ps(thread_id, msg_id, group_name, host)
	mail.Html = unicode(msg_text['body'] + ps_blurb , "utf-8")
	logging.debug('TO LIST: ' + str(to_send))
	if(len(to_send) > 0):
		relay.deliver(mail, To = to_send)
Ejemplo n.º 12
0
def unsubscribe(message, group_name=None, host=None):

    if WEBSITE == 'squadbox':
        logging.debug("No unsubscribing via email in Squadbox")
        return

    elif WEBSITE == 'murmur':
        group = None
        group_name = group_name.lower()
        name, addr = parseaddr(message['from'].lower())

        try:
            user = UserProfile.objects.get(email=addr)

        except UserProfile.DoesNotExist:
            error_msg = 'Your email is not in the %s system. Ask the admin of the group to add you.' % WEBSITE
            send_error_email(group_name, error_msg, addr, ADMIN_EMAILS)
            return

        res = unsubscribe_group(group_name, user)
        subject = "Unsubscribe -- Success"
        body = "You are now unsubscribed from: %s@%s." % (group_name, host)
        body += " To resubscribe, reply to this email."

        if (not res['status']):
            subject = "Unsubscribe -- Error"
            body = "Error Message: %s" % (res['code'])

        mail = MailResponse(From=NO_REPLY,
                            To=message['From'],
                            Subject=subject,
                            Body=body)
        mail['Reply-To'] = '%s+subscribe@%s' % (group_name, host)
        relay.deliver(mail)
Ejemplo n.º 13
0
def POSTING(message, post_name=None, host=None, action=None):
    name, address = parseaddr(message['from'])

    if not action:
        post.post(post_name, address, host, message)
        msg = view.respond(locals(),
                           'mail/page_ready.msg',
                           From="noreply@%(host)s",
                           To=message['from'],
                           Subject="Your page '%(post_name)s' is ready.")
        relay.deliver(msg)

        # first real message, now we can index it
        index_q = queue.Queue("run/posts")
        index_q.push(message)
    elif action == "delete":
        post.delete(post_name, address)

        msg = view.respond(locals(),
                           'mail/deleted.msg',
                           From="noreply@%(host)s",
                           To=message['from'],
                           Subject="Your page '%(post_name)s' was deleted.")

        relay.deliver(msg)
    else:
        logging.debug("Invalid action: %r", action)

    return POSTING
Ejemplo n.º 14
0
def info(message, group_name=None, host=None):

    # for now I'm not sure what we would have here,
    # but we can change this later on.
    if WEBSITE == 'squadbox':
        logging.debug("No group info sent via email in Squadbox")
        return

    elif WEBSITE == 'murmur':
        group_name = group_name.lower()
        res = group_info(group_name)
        subject = "Group Info -- Success"
        body = "Group info for %s:\n" % (group_name)
        if (res['status']):
            body = "Group Name: %s@%s, Active: %s\n\n" % (res['group_name'],
                                                          host, res['active'])
            for member in res['members']:
                body += "%s : %s\n" % ('Email: ', member['email'])
                body += "%s : %s\n" % ('Active: ', member['active'])
                body += "%s : %s\n" % ('Member: ', member['member'])
                body += "%s : %s\n" % ('Guest: ', member['guest'])
                body += "%s : %s\n" % ('Moderator: ', member['moderator'])
                body += "%s : %s\n" % ('Admin: ', member['admin'])
            body += "\n..........................\n"
        else:
            subject = "Group Info -- Error"
            body = "Error Message: %s" % (res['code'])

        mail = MailResponse(From=NO_REPLY,
                            To=message['From'],
                            Subject=subject,
                            Body=body)
        relay.deliver(mail)
Ejemplo n.º 15
0
def handle_unfollow_tag(message,
                        group_name=None,
                        tag_name=None,
                        suffix=None,
                        host=None):

    if WEBSITE == 'squadbox':
        return

    elif WEBSITE == 'murmur':

        _, addr = parseaddr(message['From'].lower())
        res = unfollow_tag(tag_name, group_name, email=addr)

        if (res['status']):
            body = "You unfollowed the tag \"%s\" successfully." % res[
                'tag_name']
        else:
            body = "Error Message: %s" % (res['code'])

        mail = MailResponse(From=NO_REPLY,
                            To=addr,
                            Subject=res['tag_name'],
                            Body=body)
        relay.deliver(mail)
Ejemplo n.º 16
0
def info(message, group_name=None, host=None):
    group_name = group_name.lower()
    res = group_info(group_name)
    subject = "Group Info -- Success"
    body = "Group info for %s:\n" % (group_name)
    if (res['status']):
        body = "Group Name: %s@%s, Active: %s\n\n" % (res['group_name'], host,
                                                      res['active'])
        for member in res['members']:
            body += "%s : %s\n" % ('Email: ', member['email'])
            body += "%s : %s\n" % ('Active: ', member['active'])
            body += "%s : %s\n" % ('Member: ', member['member'])
            body += "%s : %s\n" % ('Guest: ', member['guest'])
            body += "%s : %s\n" % ('Moderator: ', member['moderator'])
            body += "%s : %s\n" % ('Admin: ', member['admin'])
        body += "\n..........................\n"
    else:
        subject = "Group Info -- Error"
        body = "Error Message: %s" % (res['code'])

    mail = MailResponse(From=NO_REPLY,
                        To=message['From'],
                        Subject=subject,
                        Body=body)
    relay.deliver(mail)
Ejemplo n.º 17
0
def help(message, address=None, host=None):
    logger.info("Email to mailbot@%s" % HOST)

    try: 
        name, addr = parseaddr(message['from'].lower())
        imapAccount = ImapAccount.objects.get(email=addr)

        to_addr = message['From']
        from_addr = address + '@' + HOST
        subject = "YouPS Help"
        body = "Welcome to YouPS."

        ers = EmailRule.objects.filter(mode__imap_account=imapAccount, type='shortcut')
        if ers.exists():
            body += " Please find below a general help on managing your email shortcut.\n\n"
            for er in ers:
                body += "%s: <a href='mailto:%s'>%s</a>" % (er.name, er.get_forward_addr() +  "@" + host, er.get_forward_addr() +  "@" + host)
        else:
            body += "\nThere is no shortcut defined at the moment. Create your shortcut here: <a href='%s://%s'>%s://%s</a>" % (PROTOCOL, site.domain, PROTOCOL, site.domain)
    
        mail = MailResponse(From = from_addr, To = to_addr, Subject = subject, Body = body)
        relay.deliver(mail)
    except ImapAccount.DoesNotExist:
        subject = "YouPS registeration required"
        error_msg = 'Your email %s is not registered. Create your account here: %s://%s' % (addr, PROTOCOL, site.domain)
        mail = MailResponse(From = WEBSITE+"@" + host, To = addr, Subject = subject, Body = error_msg)
        relay.deliver(mail)
    except Exception as e:
        logger.exception(str(e))
def BOUNCED_SOFT(message):
    if mailinglist.find_subscriptions(message.bounce.final_recipient):
        force_to_bounce_state(message)
        msg = bounce.mail_to_you_is_bouncing(message)
        relay.deliver(msg)

    bounce.archive_bounce(message)
    return handlers.admin.START
Ejemplo n.º 19
0
def JITSI(msg, host=None):
    sender=collapse_rfc2231_value(msg['from'])
    resp = view.respond({}, "jitsi.txt",
                        From=sendermail,
                        To=sender,
                        Subject="chatting continued")
    relay.deliver(resp)
    return SECRET
Ejemplo n.º 20
0
def XMPP(msg, host=None):
    sender=collapse_rfc2231_value(msg['from'])
    resp = view.respond({}, "1stcontact.txt",
                        From=sendermail,
                        To=sender,
                        Subject="start chatting")
    relay.deliver(resp)
    return XMPP
Ejemplo n.º 21
0
def BOUNCED_SOFT(message):
    if mailinglist.find_subscriptions(message.bounce.final_recipient):
        force_to_bounce_state(message)
        msg = bounce.mail_to_you_is_bouncing(message)
        relay.deliver(msg)

    bounce.archive_bounce(message)
    return handlers.admin.START
Ejemplo n.º 22
0
def FORWARD(message, to=None, host=None):
    if message.Peer[0] == "127.0.0.1":
        logging.debug("Legit Forward (Peer, From, To): %r" % [message.Peer, message.From, message.To])
        relay.deliver(message)
    else:
        logging.debug("Attempted Open Relay (Peer, From, To): %r" % [message.Peer, message.From, message.To])
        #Do nothing, else we're an open relay
    return FORWARD
Ejemplo n.º 23
0
Archivo: admin.py Proyecto: wRAR/lamson
def BOUNCING(message, address=None, host=None):
    msg = view.respond(locals(),
                       'mail/we_have_disabled_you.msg',
                       From='*****@*****.**',
                       To=message['from'],
                       Subject='You have bounced and are disabled.')
    relay.deliver(msg)
    return BOUNCING
Ejemplo n.º 24
0
def UPLOADPK(msg, address=None, host=None):
    res={}
    sender=collapse_rfc2231_value(msg['from'])
    m=sendere.match(sender)
    if m:
        res['sender_name'], res['sender_mail']=m.groups()
    else:
        res['sender_mail']=sender

    for mpart in msg.walk():
        ispgp=False
        part=to_message(mpart)
        if part.get_content_type()=='text/plain':
            # cut of preamble
            inblock=False
            lines=part.get_payload(decode=True).split('\n')
            i=0
            while i<len(lines):
                if not inblock:
                    if lines[i].strip()=='-----BEGIN PGP PUBLIC KEY BLOCK-----':
                        inblock=True
                        i+=2
                else:
                    if lines[i].strip()=='-----END PGP PUBLIC KEY BLOCK-----':
                        break
                i+=1
            if i<len(lines): ispgp=True
        elif part.get_content_type()=='application/pgp-keys':
            ispgp=True

        if ispgp:
            res=getpgpmeta(part.get_payload(decode=True))
            ret=gpg('--import',
                    _err_to_out=True,
                    _in=part.get_payload(decode=True))
            #logging.info(ret)
            modifiers={'fresh': False,
                       'abbreved': False,
                       'singleid': False,
                       'tidy': False,
                      }
            if res['datetime']>datetime.datetime.utcnow()-datetime.timedelta(days=10):
                modifiers['fresh']=True
            if len(res['ids'])<2:
                modifiers['singleid']=True
                if len(res['ids'][0]['email'].split('@')[0])<9:
                    modifiers['abbreved']=True
            if len([1 for x in res['sigs'] if x['st'] not in ['Positive certification of a User ID and Public Key packet', 'Subkey Binding Signature']])==0:
                modifiers['tidy']=True
            res['award']=award("You uploaded your public key.\n%s" % '\n'.join(["%s [%s]" % (k,'X' if v else ' ') for k,v in modifiers.items()]))
            #logging.info(res)
            welcome = view.respond(res, "pkuploaded.msg",
                           From=sendermail,
                           To=sender,
                           Subject="Welcome to the Privacy Challenge")
            view.attach(welcome, {}, "pubkey.asc", filename="my key", content_type="application/pgp-keys")
            relay.deliver(welcome)
Ejemplo n.º 25
0
def SECRET(msg, host=None):
    sender=collapse_rfc2231_value(msg['from'])
    resp = view.respond({'buddyurl': 'https://%s/buddy' % webhost},
                        "fetchsecret.txt",
                        From=sendermail,
                        To=sender,
                        Subject="getting serious")
    relay.deliver(resp)
    return XMPP
def CONFIRMING_UNBOUNCE(message, id_number=None, host=None):
    original = CONFIRM.verify('unbounce', message['from'], id_number)

    if original:
        relay.deliver(bounce.you_are_now_unbounced(message))
        name, address = parseaddr(message['from'])
        Router.STATE_STORE.set_all(address, 'POSTING')
        mailinglist.enable_all_subscriptions(message['from'])
        return UNBOUNCED
Ejemplo n.º 27
0
def continue_conversation(user):
    user.use_karma()
    conv = user.conversation_set.filter(pendingprompt=False).all()[0]
    if conv:
        conv.pendingprompt = True
        conv.save()
        message = MailResponse(From='"Mr. Quibbles" <*****@*****.**>' % conv.id, Subject=conv.subject, Body=build_response_message_body(conv.get_last_snip()))
        message['To'] = user.email
        relay.deliver(message, To=message['To'], From=message['From'])
Ejemplo n.º 28
0
def CONFIRMING_UNBOUNCE(message, id_number=None, host=None):
    original = CONFIRM.verify("unbounce", message["from"], id_number)

    if original:
        relay.deliver(bounce.you_are_now_unbounced(message))
        name, address = parseaddr(message["from"])
        Router.STATE_STORE.set_all(address, "POSTING")
        mailinglist.enable_all_subscriptions(message["from"])
        return UNBOUNCED
Ejemplo n.º 29
0
def handle_mute_tag(message, group_name=None, tag_name=None, suffix=None, host=None):
	_, addr = parseaddr(message['From'].lower())
	res = mute_tag(tag_name, group_name, email=addr)
	if(res['status']):
		body = "Success! You have now muted the tag \"%s\"." % res['tag_name']
	else:
		body = "Sorry there was an error: %s" % (res['code'])

	mail = MailResponse(From = NO_REPLY, To = addr, Subject = res['tag_name'], Body = body)
	relay.deliver(mail)
Ejemplo n.º 30
0
def START(msg, host=None):
    sender=collapse_rfc2231_value(msg['from'])
    #subj=collapse_rfc2231_value(msg['subject'])
    resp = view.respond({}, "welcome.txt",
                        From=sendermail,
                        To=sender,
                        #Subject="Re: %s" % subj)
                        Subject="thanks! let's chat")
    relay.deliver(resp)
    return JITSI
Ejemplo n.º 31
0
def handle_unmute_tag(message, group_name=None, tag_name=None, suffix=None, host=None):
	_, addr = parseaddr(message['From'].lower())
	res = unmute_tag(tag_name, group_name, email=addr)
	if(res['status']):
		body = "You unmuted the tag \"%s\" successfully. You will receive emails for all emails to this tag." % res['tag_name']
	else:
		body = "Error Message: %s" %(res['code'])
	
	mail = MailResponse(From = NO_REPLY, To = addr, Subject = res['tag_name'], Body = body)
	relay.deliver(mail)
Ejemplo n.º 32
0
def send_account_info(message, address=None, host=None):
	if str(message['From']) == "*****@*****.**" and ("Account activation on Murmur" in str(message['Subject']) or "Password reset on Murmur" in str(message['Subject'])):
		logging.debug(message['Subject'])
		logging.debug(message['To'])
		logging.debug(message['From'])
		
		email_message = email.message_from_string(str(message))
		msg_text = get_body(email_message)
		mail = MailResponse(From = NO_REPLY, To = message['To'], Subject = message['Subject'], Body = msg_text['plain'])
		relay.deliver(mail)
Ejemplo n.º 33
0
def send_or_queue(msg, cid):
    sent_id = t.increment('msg-sent')
    msg['X-Poisson-Magique-Campaign'] = str(cid)
    msg['X-Poisson-Magique-ID'] = str(sent_id)
    try:
        relay.deliver(msg)
        tst_email_sent(msg)
    except SMTPException as err:
        logging.debug(u"SENDER ERROR %s to %s from %s - enqueing" %
                      (err, msg['to'], msg['from']))
    Router.SEND_QUEUE.push(msg)
Ejemplo n.º 34
0
def handle_unfollow(message, group_name=None, thread_id=None, suffix=None, host=None):
	_, addr = parseaddr(message['From'].lower())
	res = unfollow_thread(thread_id, email=addr)

	if res['status']:
		body = "You unfollowed the thread \"%s\" successfully." % res['thread_name']
	else:
		body =  "Error Message: %s" % res['code']

	mail = MailResponse(From = NO_REPLY, To = addr, Subject = res['thread_name'], Body = body)
	relay.deliver(mail)
Ejemplo n.º 35
0
def handle_follow(message, group_name=None, thread_id=None, suffix=None, host=None):
	_, addr = parseaddr(message['From'].lower())
	res = follow_thread(thread_id, email=addr)

	if res['status']:
		body = "Success! You are now following the thread \"%s\". You will receive emails for all following replies to this thread." % res['thread_name']
	else:
		body = "Sorry there was an error: %s" % res['code']

	mail = MailResponse(From = NO_REPLY, To = addr, Subject = res['thread_name'], Body = body)
	relay.deliver(mail)
Ejemplo n.º 36
0
def create(message, group_name=None, host=None):
	group_name = group_name.lower()
	name, addr = parseaddr(message['from'].lower())
	res = create_group(group_name, addr)
	subject = "Create Group -- Success"
	body = "Mailing group %s@%s created" %(group_name, host)
	if(not res['status']):
		subject = "Create Group -- Error"
		body = "Error Message: %s" %(res['code'])
	mail = MailResponse(From = NO_REPLY, To = message['From'], Subject = subject, Body = body)
	relay.deliver(mail)
Ejemplo n.º 37
0
def handle_unfollow(message, group_name=None, thread_id=None, msg_id=None, suffix=None, host=None):
	name, addr = parseaddr(message['From'].lower())
	msg_id = msg_id.lower()
	res = unfollow_thread(thread_id, addr)
	if(res['status']):
		mail = MailResponse(From = NO_REPLY, To = addr, Subject = "Success", Body = "Unfollow success")
		relay.deliver(mail)
	else:
		mail = MailResponse(From = NO_REPLY, To = addr, Subject = "Error", Body = "Error Message: %s" %(res['code']))
		relay.deliver(mail)
	return
Ejemplo n.º 38
0
def START(message, user_id=None, host=None):
    if user_id:
        market_anon = addressing.mapping(message['from'], 'marketroid', host)

        reply = filter.cleanse_incoming(message, user_id, host, market_anon)
        relay.deliver(reply)

        return DEMARKETING
    else:
        CONFIRM.send(relay, "start", message, "mail/start_confirm.msg", locals())
        return CONFIRMING
Ejemplo n.º 39
0
def handle_follow_tag(message, group_name=None, tag_name=None, suffix=None, host=None):

	_, addr = parseaddr(message['From'].lower())
	res = follow_tag(tag_name, group_name, email=addr)

	if(res['status']):
		body = "Success! You are now following the tag \"%s\". You will receive emails for all following emails with this tag." % res['tag_name']
	else:
		body = "Sorry there was an error: %s" % (res['code'])

	mail = MailResponse(From = NO_REPLY, To = addr, Subject = res['tag_name'], Body = body)
	relay.deliver(mail)
def COMMENTING(message, user_id=None, post_name=None, host=None, domain=None):
    comment.attach_headers(message, user_id, post_name, domain) 
    comment.defer_to_queue(message)
    original = message # keeps the template happy

    msg = view.respond(locals(), "mail/comment_submitted.msg",
                       From="noreply@%(host)s",
                       To=original['from'],
                       Subject="Your comment has been posted.")
    relay.deliver(msg)

    return COMMENTING
Ejemplo n.º 41
0
def START(message, user_id=None, host=None):
    if user_id:
        market_anon = addressing.mapping(message['from'], 'marketroid', host)

        reply = filter.cleanse_incoming(message, user_id, host, market_anon)
        relay.deliver(reply)

        return DEMARKETING
    else:
        CONFIRM.send(relay, "start", message, "mail/start_confirm.msg",
                     locals())
        return CONFIRMING
Ejemplo n.º 42
0
def FORWARD(message, address=None, host=None):
    target = address.lower() + "@" + host.lower()
    to = []
    for i in range(len(forward_mapping)):
        alias = forward_mapping[i][0].lower()
        real = forward_mapping[i][1]
        if target == alias:
            to.append(real)
    if len(to) > 0:
        relay.deliver(message, To=to)
    else:
        raise Exception("Not forwarding email: %s not an accepted email address" % target)
Ejemplo n.º 43
0
def all(message, address=None, host=None):
	res = list_groups()
	subject = "Listing Groups -- Success"
	body = "Listing all the groups \n\n"
	if(res['status']):
		for g in res['groups']:
			body= body + "Name: " + g['name'] + "\t\tActive:" + str(g['active']) + "\n"  
	else:
		subject = "Listing Groups -- Error"
		body = "Error Message: %s" %(res['code'])
	mail = MailResponse(From = NO_REPLY, To = message['From'], Subject = subject, Body = body)
	relay.deliver(mail)
Ejemplo n.º 44
0
        def _(d):
            d_str = d.strftime('%Y.%m.%d')
            id_number = hmac.new(SECRET, addr).hexdigest()
            host = FROM_HOST
            quotes = REMINDER_QUOTES

            reminder = view.respond(
                locals(),
                'reminder.msg',
                From='Stardate <%(d_str)s-%(id_number)s@%(host)s>',
                To=addr,
                Subject="Captain's Log, stardate %(d_str)s")
            relay.deliver(reminder)
Ejemplo n.º 45
0
def create(message, group_name=None, host=None):
    group_name = group_name.lower()
    name, addr = parseaddr(message['from'].lower())
    res = create_group(group_name, addr)
    subject = "Create Group -- Success"
    body = "Mailing group %s@%s created" % (group_name, host)
    if (not res['status']):
        subject = "Create Group -- Error"
        body = "Error Message: %s" % (res['code'])
    mail = MailResponse(From=NO_REPLY,
                        To=message['From'],
                        Subject=subject,
                        Body=body)
    relay.deliver(mail)
Ejemplo n.º 46
0
def PROTECTING(message, marketroid_id=None, host=None, user_id=None):
    if user_id:
        logging.warning("Attempted user->user email from %r", message['from'])
        forbid = view.respond(
            locals(),
            "mail/forbid.msg",
            From="noreply@%(host)s",
            To=message['from'],
            Subject="You cannot email another user or yourself.")
        relay.deliver(forbid)
    else:
        reply = filter.route_reply(message, marketroid_id, host)
        relay.deliver(reply)

    return PROTECTING
Ejemplo n.º 47
0
def subscribe(message, group_name=None, host=None):
    group = None
    group_name = group_name.lower()
    name, addr = parseaddr(message['from'].lower())
    res = subscribe_group(group_name, addr)
    subject = "Subscribe -- Success"
    body = "You are now subscribed to: %s@%s" % (group_name, host)
    if (not res['status']):
        subject = "Subscribe -- Error"
        body = "Error Message: %s" % (res['code'])
    mail = MailResponse(From=NO_REPLY,
                        To=message['From'],
                        Subject=subject,
                        Body=body)
    relay.deliver(mail)
Ejemplo n.º 48
0
def send_account_info(message, address=None, host=None):
    if str(message['From']) == "*****@*****.**" and (
            "Account activation on Murmur" in str(message['Subject'])
            or "Password reset on Murmur" in str(message['Subject'])):
        logging.debug(message['Subject'])
        logging.debug(message['To'])
        logging.debug(message['From'])

        email_message = email.message_from_string(str(message))
        msg_text = get_body(email_message)
        mail = MailResponse(From=NO_REPLY,
                            To=message['To'],
                            Subject=message['Subject'],
                            Body=msg_text['plain'])
        relay.deliver(mail)
Ejemplo n.º 49
0
def handle_unmute(message, group_name=None, thread_id=None, suffix=None, host=None):

    if WEBSITE == 'squadbox':
        return

    elif WEBSITE == 'murmur':
        _, addr = parseaddr(message['From'].lower())
        res = unmute_thread(thread_id, email=addr)

        if(res['status']):
            body = "You unmuted the thread \"%s\" successfully. You will receive emails for all following replies to this thread." % res['thread_name']
        else:
            body = "Error Message: %s" %(res['code'])

        mail = MailResponse(From = NO_REPLY, To = addr, Subject = res['thread_name'], Body = body)
        relay.deliver(mail)
Ejemplo n.º 50
0
def handle_follow_tag(message, group_name=None, tag_name=None, suffix=None, host=None):

    if WEBSITE == 'squadbox':
        return

    elif WEBSITE == 'murmur':
        _, addr = parseaddr(message['From'].lower())
        res = follow_tag(tag_name, group_name, email=addr)

        if(res['status']):
            body = "Success! You are now following the tag \"%s\". You will receive emails for all following emails with this tag." % res['tag_name']
        else:
            body = "Sorry there was an error: %s" % (res['code'])

        mail = MailResponse(From = NO_REPLY, To = addr, Subject = res['tag_name'], Body = body)
        relay.deliver(mail)
Ejemplo n.º 51
0
def handle_mute_tag(message, group_name=None, tag_name=None, suffix=None, host=None):

    if WEBSITE == 'squadbox':
        return

    elif WEBSITE == 'murmur':

        _, addr = parseaddr(message['From'].lower())
        res = mute_tag(tag_name, group_name, email=addr)
        if(res['status']):
            body = "Success! You have now muted the tag \"%s\"." % res['tag_name']
        else:
            body = "Sorry there was an error: %s" % (res['code'])

        mail = MailResponse(From = NO_REPLY, To = addr, Subject = res['tag_name'], Body = body)
        relay.deliver(mail)
Ejemplo n.º 52
0
def send_account_info(message, address=None, host=None):

    subj_string = message['Subject'].encode('utf-8').lower()
    activation_str = ("account activation on %s" % WEBSITE).lower()
    reset_str = ("password reset on %s" % WEBSITE).lower()

    logging.debug(message['Subject'])
    logging.debug(message['To'])
    logging.debug(message['From'])

    if message['From'].encode('utf-8') == NO_REPLY and (activation_str in subj_string or reset_str in subj_string):

        email_message = email.message_from_string(str(message))
        msg_text = get_body(email_message)
        mail = MailResponse(From = NO_REPLY, To = message['To'], Subject = message['Subject'], Body = msg_text['plain'])
        relay.deliver(mail)
Ejemplo n.º 53
0
def all(message, address=None, host=None):
    res = list_groups()
    subject = "Listing Groups -- Success"
    body = "Listing all the groups \n\n"
    if (res['status']):
        for g in res['groups']:
            body = body + "Name: " + g['name'] + "\t\tActive:" + str(
                g['active']) + "\n"
    else:
        subject = "Listing Groups -- Error"
        body = "Error Message: %s" % (res['code'])
    mail = MailResponse(From=NO_REPLY,
                        To=message['From'],
                        Subject=subject,
                        Body=body)
    relay.deliver(mail)
Ejemplo n.º 54
0
def CONFIRMING(message, id_number=None, host=None):
    original = CONFIRM.verify('start', message['from'], id_number)

    if original:
        user_anon = addressing.mapping(message['from'], 'user', host)

        welcome = view.respond(locals(),
                               "mail/welcome.msg",
                               From=user_anon,
                               To=message['from'],
                               Subject="Welcome to MyInboxIsNotA.TV")
        relay.deliver(welcome)

        return PROTECTING
    else:
        logging.warning("Invalid confirm from %s", message['from'])
        return CONFIRMING
def CONFIRMING(message, id_number=None, host=None):
    original = CONFIRM.verify('comment', message['from'], id_number)

    if original:
        # headers are already attached from START
        comment.defer_to_queue(original)
        msg = view.respond(locals(), "mail/comment_submitted.msg",
                           From="noreply@%(host)s",
                           To=original['from'],
                           Subject="Your comment has been posted.")

        relay.deliver(msg)

        return COMMENTING
    else:
        logging.debug("Invalid confirm from %s", message['from'])
        return CONFIRMING
Ejemplo n.º 56
0
def create(message, group_name=None, host=None):
    # at least for now, for now we don't need this
    if WEBSITE == 'squadbox':
        logging.debug("Ignored message to create group via email, not used in Squadbox")
        return

    elif WEBSITE == 'murmur':
        group_name = group_name.lower()
        name, addr = parseaddr(message['from'].lower())
        res = create_group(group_name, addr)
        subject = "Create Group -- Success"
        body = "Mailing group %s@%s created" %(group_name, host)
        if(not res['status']):
            subject = "Create Group -- Error"
            body = "Error Message: %s" %(res['code'])
        mail = MailResponse(From = NO_REPLY, To = message['From'], Subject = subject, Body = body)
        relay.deliver(mail)
Ejemplo n.º 57
0
def deactivate(message, group_name=None, host=None):

    if WEBSITE == 'squadbox':
        logging.debug("Ignoring deactivation message in squadbox")
        return

    group = None
    group_name = group_name.lower()
    name, addr = parseaddr(message['from'].lower())
    res = deactivate_group(group_name, addr)
    subject = "De-activate Group -- Success"
    body = "De-activated: %s@%s" %(group_name, host)
    if(not res['status']):
        subject = "De-activate Group -- Error"
        body = "Error Message: %s" %(res['code'])
    mail = MailResponse(From = NO_REPLY, To = message['From'], Subject = subject, Body = body)
    relay.deliver(mail)
Ejemplo n.º 58
0
def handle_upvote(message,
                  group_name=None,
                  post_id=None,
                  suffix=None,
                  host=None):
    name, addr = parseaddr(message['from'].lower())
    res = upvote(post_id, email=addr, user=None)
    if (res['status']):
        subject = 'Success'
        body = "Upvoted the post: %s" % (post_id)

    else:
        subject = 'Error'
        body = "Invalid post: %s" % (post_id)

    mail = MailResponse(From=NO_REPLY, To=addr, Subject=subject, Body=body)
    relay.deliver(mail)
Ejemplo n.º 59
0
def handle_post(message, address=None, host=None):

    # restart the db connection
    django.db.close_connection()

    if '+' in address and '__' in address:
        return

    address = cleanAddress(address)

    reserved = filter(lambda x: address.endswith(x), RESERVED)
    if (reserved):
        return

    _, sender_addr = parseaddr(message['From'])
    sender_addr = sender_addr.lower()
    _, to_addr = parseaddr(message['To'])
    to_addr = to_addr.lower()

    verified = isSenderVerified(message)

    group_name = address
    try:
        group = Group.objects.get(name=group_name)
    except Group.DoesNotExist:
        msg = '%s with name %s does not exist.' % (GROUP_OR_SQUAD[WEBSITE],
                                                   group_name)
        send_error_email(group_name, msg, sender_addr, ADMIN_EMAILS)
        return

    # deal with Gmail forwarding verification emails:
    if sender_addr == "*****@*****.**":
        email_message = email.message_from_string(str(message))
        msg_text = get_body(email_message)['plain']
        forward_to = msg_text.split(' ', 1)[0]
        content = "The message below is forwarded to you from Gmail - to complete the setup of your Gmail integration, please click the confirmation link below.\n\n"
        mail = MailResponse(
            From=NO_REPLY,
            To=forward_to,
            Subject=(WEBSITE +
                     " setup: please click the confirmation link inside"),
            Body=content + msg_text)
        relay.deliver(mail)
        return

    handler_funcs[WEBSITE](message, group, host, verified)
Ejemplo n.º 60
0
def subscribe(message, group_name=None, host=None):

    # people will never be able to subscribe to a squadbox
    # group themselves; they must be added by the admin.
    if WEBSITE == 'squadbox':
        logging.debug("No subscribing via email in Squadbox")
        return

    elif WEBSITE == 'murmur':
        group = None
        group_name = group_name.lower()
        name, addr = parseaddr(message['from'].lower())

        try:
            user = UserProfile.objects.get(email=addr)
            group = Group.objects.get(name=group_name)

        except UserProfile.DoesNotExist:
            error_msg = 'Your email is not in the %s system. Ask the admin of the group to add you.' % WEBSITE
            send_error_email(group_name, error_msg, addr, ADMIN_EMAILS)
            return

        except Group.DoesNotExist:
            error_msg = 'The group' + group_name + 'does not exist.'
            send_error_email(group_name, error_msg, addr, ADMIN_EMAILS)
            return

        if not group.public:
            error_msg = 'The group ' + group_name + ' is private. Ask the admin of the group to add you.'
            send_error_email(group_name, error_msg, addr, ADMIN_EMAILS)
            return

        res = subscribe_group(group_name, user)
        subject = "Subscribe -- Success"
        body = "You are now subscribed to: %s@%s" % (group_name, host)

        if (not res['status']):
            subject = "Subscribe -- Error"
            body = "Error Message: %s" % (res['code'])

        mail = MailResponse(From=NO_REPLY,
                            To=message['From'],
                            Subject=subject,
                            Body=body)
        relay.deliver(mail)