def send_subscribe_mail(p, member): logger.debug("---------------------------match result " + p.name_cn + " member id = " + member.first_name) recommend = GlobalRecommendProjectLog() recommend.member_id = member.id recommend.project_id = p.id recommend.email = member.email recommend.save() try: email = member.email mail_dic = dict() mail_dic['p'] = p mail_dic['username'] = member.first_name mail_dic['publisher_name'] = p.member.first_name mail_dic['subscribe_name'] = p.name_cn handle_dynamic_email_module(mail_dic, p) key = "global subscribe" member_info = str(member.id) + "," + member.email encrypt_result = custom_crypto.encrypt(key, member_info) mail_dic['disable_push_link'] = _get_disable_push_link(encrypt_result) html_content = loader.render_to_string("subscribe/email_send_global_subscribe.html", mail_dic) title = u'Newchama项目推荐' logger.info("sending email " + email) if not IS_PRODUCT_HOST: email = TEST_EMAIL send_email_by_mq('email', 'email', title, email, html_content) # msg = EmailMessage(title, html_content, EMAIL_HOST_USER, [email]) # msg.content_subtype = "html" # Main content is now text/html # msg.send() except Exception, e: logger.error(e.message, exc_info=True)
def _send_publish_message_email(email, name): mail_dic = dict() mail_dic['email'] = email mail_dic['name'] = name html_content = loader.render_to_string( "analysis/email_has_nopublish_message.html", mail_dic) title = u'NewChama用户未发送项目邮件通知' try: send_email_by_mq('email', 'email', title, email, html_content) except Exception, e: msg = EmailMessage(title, html_content, EMAIL_HOST_USER, [email]) msg.content_subtype = "html" # Main content is now text/html msg.send()
def send_pro_to_inneruser(request): mem_id = check_access_token(request) c = {} c["message"] = "Fail to send pro to inner user" c["status"] = "fail" request_data = request.DATA if len(request_data) > 0: pro_id = request_data["pro_id"] project = Project.objects.get(id=pro_id) receiver_id = request_data["receiver_id"] receiver = Member.objects.get(id=receiver_id) receiver_email = receiver.email if mem_id and receiver_id: emailAccount = [] dic = {} if receiver.fullname.strip(): dic["userName"] = receiver.fullname dic["link"] = _get_project_link(pro_id) if project.name_cn.strip() != "": dic["projectName"] = project.name_cn else: dic["projectName"] = project.name_en html_content = loader.render_to_string( "sales/" + request.lang + "/email_push.html", dic) emailAccount.append(receiver_email) title = _('NewChama Project Message') try: send_email_by_mq('email', 'email', title, set(emailAccount), html_content) c["status"] = "success" c["message"] = "ok" except Exception, e: msg = EmailMessage(title, html_content, EMAIL_HOST_USER, set(emailAccount)) msg.content_subtype = "html" # Main content is now textml msg.send() autoMsg = Message() autoMsg.project_id = pro_id autoMsg.type_relation = 1 autoMsg.sender_id = mem_id autoMsg.receiver_id = receiver_id autoMsg.content = "您好,这是我的项目Teaser。若您对此感兴趣,欢迎与我取得联系。" autoMsg.save()
def _send_login_message_email(email, is_sales, plist): mail_dic = dict() mail_dic['email'] = email mail_dic['is_sales'] = is_sales mail_dic['list'] = plist html_content = loader.render_to_string( "analysis/email_has_nologin_message.html", mail_dic) title = u'NewChama用户未登录邮件通知' try: send_email_by_mq('email', 'email', title, email, html_content) except Exception, e: msg = EmailMessage(title, html_content, EMAIL_HOST_USER, [email]) msg.content_subtype = "html" # Main content is now text/html msg.send()