def sendmail(listname): mlist = get_mailinglist(listname, lock=False) context = {} context['email_to'] = mlist.GetListEmail() context['message_id'] = uuid.uuid1() context['ip_from'] = request.environ.get('REMOTE_ADDR') context['timestamp'] = get_timestamp() context['name_from'] = request.forms.get('name_from') context['email_from'] = request.forms.get('email_from') context['subject'] = request.forms.get('subject') context['body'] = request.forms.get('body') in_reply_to = request.forms.get('in_reply_to') if in_reply_to: context['in_reply_to'] = in_reply_to if None in context.values(): return jsonify('Missing information. `email_from`, `subject` and ' '`body` are mandatory', 400) email = template(EMAIL_TEMPLATE, context) Post.inject(listname, email.encode('utf8'), qdir=mm_cfg.INQUEUE_DIR) return jsonify(True)
def sendmail(listname): """Posts an email to the mailing list. **Method**: POST **URI**: /<listname>/sendmail **Parameters**: * `name_from`: name of the poster * `email_from`: email address of the poster * `subject`: the subject of the message * `body`: the body of the message. * `in_reply_to` (optional): Message-ID of the message that is being replied to, if any.""" mlist = get_mailinglist(listname, lock=False) context = {} context['email_to'] = mlist.GetListEmail() context['message_id'] = uuid.uuid1() context['ip_from'] = request.environ.get('REMOTE_ADDR') context['timestamp'] = get_timestamp() context['name_from'] = request.forms.get('name_from') context['email_from'] = request.forms.get('email_from') context['subject'] = request.forms.get('subject') context['body'] = request.forms.get('body') in_reply_to = request.forms.get('in_reply_to') if in_reply_to: context['in_reply_to'] = in_reply_to if None in context.values(): return jsonify( 'Missing information. `email_from`, `subject` and ' '`body` are mandatory', 400) email = template(EMAIL_TEMPLATE, context) Post.inject(listname, email.encode('utf8'), qdir=mm_cfg.INQUEUE_DIR) return jsonify(True)
def sendmail(listname): """Posts an email to the mailing list. **Method**: POST **URI**: /<listname>/sendmail **Parameters**: * `name_from`: name of the poster * `email_from`: email address of the poster * `subject`: the subject of the message * `body`: the body of the message. * `in_reply_to` (optional): Message-ID of the message that is being replied to, if any.""" mlist = get_mailinglist(listname, lock=False) context = {} context['email_to'] = mlist.GetListEmail() context['message_id'] = uuid.uuid1() context['ip_from'] = request.environ.get('REMOTE_ADDR') context['timestamp'] = get_timestamp() context['name_from'] = request.forms.get('name_from') context['email_from'] = request.forms.get('email_from') context['subject'] = request.forms.get('subject') context['body'] = request.forms.get('body') in_reply_to = request.forms.get('in_reply_to') if in_reply_to: context['in_reply_to'] = in_reply_to if None in context.values(): return jsonify('Missing information. `email_from`, `subject` and ' '`body` are mandatory', 400) email = template(EMAIL_TEMPLATE, context) Post.inject(listname, email.encode('utf8'), qdir=mm_cfg.INQUEUE_DIR) return jsonify(True)
context['name_from'] = request.forms.get('name_from') context['email_from'] = request.forms.get('email_from') context['subject'] = request.forms.get('subject') context['body'] = request.forms.get('body') in_reply_to = request.forms.get('in_reply_to') if in_reply_to: context['in_reply_to'] = in_reply_to result = jsonify(ERRORS_CODE['Ok']) if None in context.values(): result = jsonify(ERRORS_CODE['MissingInformation']) email = template(EMAIL_TEMPLATE, context) Post.inject(listname, email.encode('utf8'), qdir=mm_cfg.INQUEUE_DIR) return result def create_list(listname): """Create an email list. **Method**: POST **URI**: /v2/lists/<listname> **Parameters**: * `admin`: email of list admin * `password`: list admin password * `subscribe_policy`: 1) Confirm; 2) Approval; 3)Confirm and approval.
context['name_from'] = request.forms.get('name_from') context['email_from'] = request.forms.get('email_from') context['subject'] = request.forms.get('subject') context['body'] = request.forms.get('body') in_reply_to = request.forms.get('in_reply_to') if in_reply_to: context['in_reply_to'] = in_reply_to result = jsonify(ERRORS_CODE['Ok']) if None in context.values(): result = jsonify(ERRORS_CODE['MissingInformation']) email = template(EMAIL_TEMPLATE, context) Post.inject(listname, email.encode('utf8'), qdir=mm_cfg.INQUEUE_DIR) return result def create_list(listname): """Create an email list. **Method**: PUT **URI**: /v3/<listname> **Parameters**: * `admin`: email of list admin * `password`: list admin password * `subscribe_policy`: 1) Confirm; 2) Approval; 3)Confirm and approval.
attnum = 1 while attnum < 99: try: att = cgidata["attachment%02d" % attnum] except KeyError: break if att.filename: #Browser should send right mimetypes (maintype, subtype) = att.type.split('/') opt = att.type_options; data = att.file.read() if maintype == 'text': if 'encoding' not in opt: opt['encoding'] = 'utf-8' part = MIMEText(data, subtype, opt['encoding']) elif maintype == 'image': part = MIMEImage(data, subtype) elif maintype == 'audio': part = MIMEAudio(data, subtype) elif maintype == 'application': part = MIMEApplication(data, subtype) else: part = MIMEApplication(data) part["Content-Disposition"] = "attachment; filename=" + att.filename msg.attach(part) attnum+=1; Post.inject(listname,msg) url = report_submission(msgid, 'Processing...', True) print "Status: 303 \nLocation: " + url +"\n"