def send(): # 获取per页面,get请求发送过来的数据,利用perno 查询数据库 期刊信息 name = request.args.get('name') email = request.args.get('email') per_no = request.args.get('perno') type = request.args.get('type') per_db = ZwMySQL() per = per_db.select_periodical_with_perno(per_no) from mail import send_editor_email_list from mail import send_paper_email_list # 尝试发送邮件,捕获异常,返回1成功,0失败 if type == 'editor': try: send_editor_email_list(per[2], name, email, per[3], per[1], per[4]) try: email_db = ZwMySQL() email_db.count_add(email) except Exception as count_error: app.logger.error("count add error %s" % count_error) return '1' except Exception as e: app.logger.error("send email error %s" % e) return str(e) elif type == 'paper': try: send_paper_email_list(per[7], name, email, per[6], per[1], per[4]) # per[6]数据库中名称为 dec_paper 后追加字段 try: email_db = ZwMySQL() email_db.count_add(email) except Exception as count_error: app.logger.error("count add error %s" % count_error) return '1' except Exception as e: app.logger.error("send email error %s" % e) return str(e) else: return 'no action'