def mail(subject="",message=""): global use_mail,sender_login,sender_pass,sender_smtp,receiver if use_mail: sender_addr = sender_login+"@"+sender_smtp.split(":")[0] send_mail(from_addr=sender_addr, to_addr_list=[receiver],subject=subject, message=message,login=sender_login, password=sender_pass,smtpserver=sender_smtp) else: return None
def send_ep_welcome_email(receiver:dict, name_of_sender:str, sender_email:str, sender_pwd:str): # Format name name = receiver['Name'].split()[0] #First Name name = name[0].upper() + name[1:] #Captilize the first letter to = [receiver['Email']] cc = [mail for name, mail in receiver['EPM']] bcc = [] bcc_entry = '' while(1): print('\nDo you want to send a welcome email to this EP?') print(f"""Name: '{name}' To: {to[0]} CC: {cc} {bcc_entry}""") choice = input("Yes(y), Change Name(c), Add BCC(b), No(n) :").lower().strip() if choice == 'y': send_mail(name, to, cc, bcc, name_of_sender, sender_email, sender_pwd, template = 'welcome') return elif choice == 'c': name = input('Enter Name :') continue elif choice == 'b': bcc = input("Please enter BCC receivers separated by commas and no spaces :").replace(' ','').split(',') if bcc != ['']: bcc_entry = 'BCC: ' + str(bcc) + '\n' else: bcc = []; bcc_entry = '' else: print('Email not sent!') return
def application(environ, start_response): start_response('200 OK', [('Content-Type', 'text/html')]) # environ是当前请求的所有数据,包括Header和URL,body,这里只涉及到get # 获取当前get请求的所有数据,返回是string类型 params = parse.parse_qs(environ['QUERY_STRING']) # 获取get中key为name的值 name = params.get('name', [''])[0] od = params.get('od', [''])[0] td = params.get('td', [''])[0] if(name=='get_163()'): return json.dumps(server1.get_163(od,td),ensure_ascii=False) elif(name=='get_douban()'): return json.dumps(server1.get_douban(od,td),ensure_ascii=False) elif(name=='get_sougou()'): return json.dumps(server1.get_sougou(od,td),ensure_ascii=False) elif(name=='get_tieba()'): return json.dumps(server1.get_tieba(od,td),ensure_ascii=False) elif(name=='png_post()'): return json.dumps(server1.png_post(od,td),ensure_ascii=False) elif(name=='send_email()'): mymail.send_mail(od,"舆论系统提醒!",td) return json.dumps("",ensure_ascii=False) elif(name=='get_more()'): if(od=='1'): return json.dumps(more.get_douban_more(td),ensure_ascii=False) elif(od=='2'): return json.dumps(more.get_tieba_more(td),ensure_ascii=False) elif(name=='get_side'): return json.dumps(emo.sentiment_score(emo.sentiment_score_list(str(od))),ensure_ascii=False)
def outError(self, text, is_send_mail= False): if self.isdebug == False: # self.logger.error(text) self.log(text) self.log(traceback.format_exc()) if is_send_mail: content = '' if traceback: content = text + '\n' + traceback.format_exc() + '\n' else: content = text + '\n' ret = mymail.send_mail(mail_config.MAILTO_LIST, mail_config.MAIL_ERROR_TITLE, content) if ret[0] is False: self.log(mail_config.SEND_MAIL_ERROR + ret[1]) else: print(text)