def check_email_address(self, email): email = email.strip() mo = self.email_re1.match(email) if mo is None: self.error("Email format is invalid: " + email.strip()) return name = mo.group(1).strip() if name == '': self.error("Name is not provided with email address: " + email) else: quoted = len(name) > 2 and name[0] == '"' and name[-1] == '"' if name.find(',') >= 0 and not quoted: self.error('Add quotes (") around name with a comma: ' + name) if mo.group(2) == '': self.error("There should be a space between the name and " + "email address: " + email) if mo.group(3).find(' ') >= 0: self.error("The email address cannot contain a space: " + mo.group(3)) if ' via Groups.Io' in name and mo.group(3).endswith('@groups.io'): self.error("Email rewritten by lists DMARC / DKIM / SPF: " + email)
def mainLoop(): title = "메일제목을 쓰세요." # attach_file="send_mail.py" <--------- 첨부파일 명입니다. 없으면 그대로 주석처리 해두세요. # f = open("text.txt", "r") # <------ 메일 내용의 Text버전이 들어있는 파일입니다. # message = f.read() # f.close() message = "메일 테스트 입니다." # f = open("html.html", "r") # <------ 메일 내용의 HTML버전이 들어있는 파일입니다. # html = f.read() # f.close() html = "" print("Program Ready") print("----------------------") f = open("list.txt", "r") # <---- 엔터키로 구분된 메일링 리스트입니다. 메일 주소가 한줄에 하나씩 있어야 합니다. emails = f.readlines() for email in emails: email = email.strip('\r') email = email.strip('\n') email = email.strip(' ') email = email.strip('\t') if email == "": continue print("[" + str(datetime.datetime.now()) + "] Sending email to " + email + "...") send_gmail(email, title, message, html, "") print("[" + str(datetime.datetime.now()) + "] Complete... Waiting for 5 seconds.") # 5초마다 보냅니다. time.sleep(5) print("Mails have just sent. The program is going to end.")
def _51job_com(self, subject, sender, date, to, body): try: # with open(subject+'.txt','w',encoding='utf8') as f: # f.write(body) company = re.compile( r""".*?应聘职位.*?word-break:break-all">(.*?)</td>.*?font-weight:normal">(.*?)</strong>.*?([男女]).*?(\d+.*?岁\(\d{4}/\d{1,2}/\d{1,2}\)).*?word-break:break-all">(\d{11}|\d{3}-\d{6,8})</td>.*?word-break:break-all"><a href="mailto:(.*?)">.*?居住地:.*?break-all">(.*?)</td>.*?""", re.S) basic = re.search(company, body) position = basic.group(1) username = basic.group(2) sex = basic.group(3) age = basic.group(4) mobile = str(basic.group(5)) email = basic.group(6) address = basic.group(7) company = re.compile(r'.*?>(.*?)<.*?', re.S) text = re.findall(company, body) html = pq(body) texts = html('body').text() self.setData([ username.strip(), age.strip(), sex.strip(), mobile.strip(), email.strip(), address.strip(), '前程无忧', texts.strip(), date, self.local.emailname, '' ]) except Exception as e: self.showMsg('前程无忧', e) pass
def old_parse_from(from_name): left=from_name.rfind("<") if left!=-1: # It is like "nick" <email> or nick <email> if from_name[0]=="\"": #It is like "nick" <email> nick=from_name[1:left-2].strip() else: #it is like nick <email> nick=from_name[0:left].strip() email=from_name[left+1:-1] else: left=from_name.rfind("(") if left!=-1: #it is like email (nick) right=from_name.rfind(")") nick=from_name[left+1:right].strip() email=from_name[0:left-1] else: #ther is only the email nick="" email=from_name if nick=="": nick=from_name return nick,email.strip()
def parseaddr_unicode(addr) -> (str, str): """Like parseaddr() but return name in unicode instead of in RFC 2047 format Should be used instead of parseaddr() '=?UTF-8?B?TmjGoW4gTmd1eeG7hW4=?= <*****@*****.**>' -> ('Nhơn Nguyễn', "*****@*****.**") """ # sometimes linebreaks are present in addr addr = addr.replace("\n", "").strip() name, email = parseaddr(addr) # email can have whitespace so we can't remove whitespace here email = email.strip().lower() if name: name = name.strip() decoded_string, charset = decode_header(name)[0] if charset is not None: try: name = decoded_string.decode(charset) except UnicodeDecodeError: LOG.warning("Cannot decode addr name %s", name) name = "" except LookupError: # charset is unknown LOG.warning( "Cannot decode %s with %s, use utf-8", decoded_string, charset ) name = decoded_string.decode("utf-8") else: name = decoded_string if type(name) == bytes: name = name.decode() return name, email
def email_verification_adress(email): addressToVerify = email.strip().lower() match = re.match('^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$', addressToVerify) is_valid = 0 if match != None: is_valid = 1 return is_valid
def get_taskoperator_emails(self, task_nr): """ Get the email adresses of all configured operators for a specific task. Return a list. """ curc, conc = c.connect_to_db(self.coursedb, self.logger_queue, self.name) data = {'TaskNr': task_nr} sql_cmd = "SELECT TaskOperator FROM TaskConfiguration WHERE TaskNr = :TaskNr" curc.execute(sql_cmd, data) result = curc.fetchone() if result != None: result = str(result[0]) taskoperator_emails = [ email.strip() for email in result.split(',') ] else: taskoperator_emails = "" conc.close() return taskoperator_emails
def add_members(group_name, emails, user): res = {'status':False} try: group = Group.objects.get(name=group_name) is_public = group.public is_admin = False if user: membergroup = MemberGroup.objects.get(group=group, member=user) is_admin = membergroup.admin if is_public or is_admin: email_list = emails.strip().lower().split(',') for email in email_list: email = email.strip() email_user = UserProfile.objects.filter(email=email) member = False if email_user.count() == 1: member = MemberGroup.objects.filter(member=email_user[0], group=group).exists() if not member: mail = MailResponse(From = 'no-reply@' + BASE_URL, To = email, Subject = "You've been subscribed to %s Mailing List" % (group_name)) if email_user.count() == 1: _ = MemberGroup.objects.get_or_create(member=email_user[0], group=group) message = "You've been subscribed to %s Mailing List. <br />" % (group_name) message += "To see posts from this list, visit <a href='http://%s/posts?group_name=%s'>http://%s/posts?group_name=%s</a><br />" % (BASE_URL, group_name, BASE_URL, group_name) message += "To manage your mailing list settings, subscribe, or unsubscribe, visit <a href='http://%s/groups/%s'>http://%s/groups/%s</a><br />" % (BASE_URL, group_name, BASE_URL, group_name) else: pw = password_generator() new_user = UserProfile.objects.create_user(email, pw) _ = MemberGroup.objects.get_or_create(group=group, member=new_user) message = "You've been subscribed to %s Mailing List. <br />" % (group_name) message += "An account to manage your settings has been created for you at <a href='http://%s'>http://%s</a><br />" % (BASE_URL, BASE_URL) message += "Your username is your email, which is %s and your auto-generated password is %s <br />" % (email, pw) message += "If you would like to change your password, please log in at the link above and then you can change it under your settings. <br />" message += "To see posts from this list, visit <a href='http://%s/posts?group_name=%s'>http://%s/posts?group_name=%s</a><br />" % (BASE_URL, group_name, BASE_URL, group_name) message += "To manage your mailing lists, subscribe, or unsubscribe from groups, visit <a href='http://%s/groups'>http://%s/my_groups</a><br />" % (BASE_URL, BASE_URL) mail.Html = message logging.debug('TO LIST: ' + str(email)) relay_mailer.deliver(mail, To = [email]) res['status'] = True else: res['code'] = msg_code['PRIVILEGE_ERROR'] except Group.DoesNotExist: res['code'] = msg_code['GROUP_NOT_FOUND_ERROR'] except MemberGroup.DoesNotExist: res['code'] = msg_code['NOT_MEMBER'] except: res['code'] = msg_code['UNKNOWN_ERROR'] logging.debug(res) return res
def check_email_address(self, email): email = email.strip() mo = self.email_re1.match(email) if mo is None: self.error("Email format is invalid: " + email.strip()) return name = mo.group(1).strip() if name == "": self.error("Name is not provided with email address: " + email) else: quoted = len(name) > 2 and name[0] == '"' and name[-1] == '"' if name.find(",") >= 0 and not quoted: self.error('Add quotes (") around name with a comma: ' + name) if mo.group(2) == "": self.error("There should be a space between the name and " + "email address: " + email) if mo.group(3).find(" ") >= 0: self.error("The email address cannot contain a space: " + mo.group(3))
def zhaopinmail_com(self, subject, sender, date, to, body): try: self.showMsg('智联招聘') # print(body) #基本资料 company = re.compile( r'.*?<td>.*?line-height:50px">(.*?)</td>.*?style="font-weight:bold">([男|女])</font>.*?weight:bold">([0-9]+年[0-9]+月).*?</font><br />(.*?)<small.*?href="(https://ihr\.zhaopin\.com.*?)".*?', re.S) basic = re.search(company, body) if basic: username = basic.group(1) sex = basic.group(2) age = basic.group(3) address = basic.group(4) url = basic.group(5) else: return False #联系方式 try: import urllib from urllib.parse import parse_qs query = urllib.parse.urlparse(url).query param = parse_qs(query)['param'][0] url = "https://ihr.zhaopin.com/resumemanage/emailim.do?s=" + param contact = requests.get(url, headers=headers).text contact = json.loads(contact) if contact['code'] == 200: username = contact['data']['username'] mobile = str(contact['data']['phone']) email = contact['data']['email'] else: return False except Exception as e: exit() self.showMsg('智联招聘1', e) return False html = pq(body) texts = html('table').text() self.setData([ username.strip(), age.strip(), sex.strip(), mobile.strip(), email.strip(), address.strip(), '智联招聘', texts.strip(), date, self.local.emailname, '' ]) except Exception as e: self.showMsg('智联招聘', e)
def update_status(email): email = email.strip() cnx = connection.MySQLConnection(user=user_name, password=Password, host=host, database=database) updateQuery = "UPDATE user SET approbation = 'WaitingForValidation' WHERE email = '" + email + "'" cursor = cnx.cursor() cursor.execute(updateQuery) cnx.commit() cnx.rollback() cursor.close()
def get_email_author(self, msg): "Returns author's name and email if any" try: header_from = msg['From'] splits = header_from.split('<', 1) name, email = splits if len(splits) == 2 else ('', header_from) email = email.split('>', 1)[0] if name: name, encoding = decode_header(name.strip(' "\''))[0] name = self.decode(name, encoding) name = name.strip(' \'"') except: email = name = None if not email: try: email = msg['Return-path'] email.strip(' \'"<>') except Exception: email = None return name, email
def add_members(group_name, emails, user): res = {'status':False} try: group = Group.objects.get(name=group_name) membergroup = MemberGroup.objects.get(group=group, member=user) if membergroup.admin: email_list = emails.strip().lower().split(',') for email in email_list: email = email.strip() mail = MailResponse(From = 'no-reply@' + BASE_URL, To = email, Subject = "You've been subscribed to %s Mailing List" % (group_name)) email_user = UserProfile.objects.filter(email=email) if email_user.count() == 1: _ = MemberGroup.objects.get_or_create(member=email_user[0], group=group) message = "You've been subscribed to %s Mailing List. <br />" % (group_name) message += "To see posts from this list, visit <a href='http://%s/posts?group_name=%s'>http://%s/posts?group_name=%s</a><br />" % (BASE_URL, group_name, BASE_URL, group_name) message += "To manage your mailing list settings, subscribe, or unsubscribe, visit <a href='http://%s/groups/%s'>http://%s/groups/%s</a><br />" % (BASE_URL, group_name, BASE_URL, group_name) else: pw = password_generator() new_user = UserProfile.objects.create_user(email, pw) _ = MemberGroup.objects.get_or_create(group=group, member=new_user) message = "You've been subscribed to %s Mailing List. <br />" % (group_name) message += "An account has been created for you at <a href='http://%s'>http://%s</a><br />" % (BASE_URL, BASE_URL) message += "Your username is your email, which is %s and your auto-generated password is %s <br />" % (email, pw) message += "If you would like to change your password, please log in at the link above and then you can change it under your settings. <br />" message += "To see posts from this list, visit <a href='http://%s/posts?group_name=%s'>http://%s/posts?group_name=%s</a><br />" % (BASE_URL, group_name, BASE_URL, group_name) message += "To manage your mailing lists, subscribe, or unsubscribe from groups, visit <a href='http://%s/groups'>http://%s/my_groups</a><br />" % (BASE_URL, BASE_URL) mail.Html = message logging.debug('TO LIST: ' + str(email)) relay_mailer.deliver(mail, To = [email]) res['status'] = True else: res['code'] = msg_code['PRIVILEGE_ERROR'] except Group.DoesNotExist: res['code'] = msg_code['GROUP_NOT_FOUND_ERROR'] except MemberGroup.DoesNotExist: res['code'] = msg_code['NOT_MEMBER'] except: res['code'] = msg_code['UNKNOWN_ERROR'] logging.debug(res) return res
def valid (self, email: str, company_id: Optional[int] = None) -> None: """Validate an ``email'' address for ``company_id''""" self.setup (company_id = company_id) if not email: raise error ('empty email') email = email.strip () if not email: raise error ('empty email (just whitespaces)') parts = email.split ('@') if len (parts) != 2: raise error ('expect exactly one "@" sign') (user, domain) = parts self.valid_user (user) self.valid_domain (domain) self.check_blacklist (email, company_id)
def get_admin_emails(self): """ Get the email adresses of all configured admins. Return a list. """ curc, conc = c.connect_to_db(self.coursedb, self.logger_queue, self.name) sql_cmd = "SELECT Content FROM GeneralConfig WHERE ConfigItem == 'admin_email'" curc.execute(sql_cmd) result = str(curc.fetchone()[0]) admin_emails = [email.strip() for email in result.split(',')] conc.close() return admin_emails
def format_mail_name(from_field): """Returns a formatted version of the 'From' field. John Doe <*****@*****.**> will return: john at doe.com (John Doe) In some cases, the 'From' field can also be formatted as: [email protected] (John Doe) We handle both the cases but the returned string is the same. """ # No regex! if from_field.startswith('<') and from_field.endswith('>'): email_start_pos = from_field.find("<") email_end_pos = from_field.find(">") email = from_field[email_start_pos+1:email_end_pos] name = email.strip("""'"<>""") return email, name if from_field.endswith('>'): # Get the position of < and > to parse the email. email_start_pos = from_field.find("<") email_end_pos = from_field.find(">") email = from_field[email_start_pos+1:email_end_pos] name_raw = from_field[:email_start_pos-1].strip() name = name_raw.strip("""'"<>""") return email, name # For the second case. elif from_field.endswith(')'): # Get the position of ( and ) to parse the name. name_start_pos = from_field.find("(") name_end_pos = from_field.find(")") name_raw = from_field[name_start_pos+1: name_end_pos] name = name_raw.strip("""'">""") email = from_field[:name_start_pos-1] return email, name # This is for badly formatted From headers. else: return '', ''
def get_taskoperator_emails(self, task_nr): """ Get the email adresses of all configured operators for a specific task. Return a list. """ curc, conc = c.connect_to_db(self.coursedb, self.logger_queue, self.name) data = {'TaskNr': task_nr} sql_cmd = "SELECT TaskOperator FROM TaskConfiguration WHERE TaskNr = :TaskNr" curc.execute(sql_cmd, data) result = str(curc.fetchone()[0]) taskoperator_emails = [email.strip() for email in result.split(',')] conc.close() return taskoperator_emails
def ganji_com(self, subject, sender, date, to, body): print('赶集') try: company = re.compile(r"(\\u[a-z0-9]{4})", re.S) text = re.findall(company, body) for i in text: a = i.encode('gbk').decode('unicode_escape') body = body.replace(i, a) # with open(subject+'.txt','w',encoding='utf8') as f: # f.write(body) company = re.compile( r""".*?font-weight:bold">(.*?)</span>.*?投递职位:.*?>(.*?)</span>.*?font-size:16px">(\1(.*?))</p>.*?工作地点:(.*?)</span>.*?电话:.*?(\d{11}).*?""", re.S) basic = re.search(company, body) if basic: position = basic.group(2) username = basic.group(1) age_sex = basic.group(3).split('(')[1].split(' ') sex = age_sex[0] age = age_sex[1].rstrip(')') address = basic.group(4) mobile = str(basic.group(5)) email = '' else: return False html = pq(body) texts = html('body').text() self.setData([ username.strip(), age.strip(), sex.strip(), mobile.strip(), email.strip(), address.strip(), '赶集', texts.strip(), date, self.local.emailname, '' ]) except Exception as e: self.showMsg('赶集', e) pass
def parseaddr_unicode(addr) -> (str, str): """Like parseaddr but return name in unicode instead of in RFC 2047 format '=?UTF-8?B?TmjGoW4gTmd1eeG7hW4=?= <*****@*****.**>' -> ('Nhơn Nguyễn', "*****@*****.**") """ name, email = parseaddr(addr) email = email.strip().lower() if name: name = name.strip() decoded_string, charset = decode_header(name)[0] if charset is not None: try: name = decoded_string.decode(charset) except UnicodeDecodeError: LOG.warning("Cannot decode addr name %s", name) name = "" else: name = decoded_string return name, email
def _58(self, subject, sender, date, to, body): try: # body = str(body) # body = body.encode('utf8') # body = body.decode('utf8') company = re.compile(r"(\\u[a-z0-9]{4})", re.S) text = re.findall(company, body) for i in text: a = i.encode('gbk').decode('unicode_escape') body = body.replace(i, a) company = re.compile( r'.*?应聘职位.*?href="(.*?)".*?target="_blank">(.*?)<.*?weight:normal;">(.*?)<span.*?>((.*?))<.*?white-space:nowrap;">现居住(.*?)</li>.*?手机号码:.*?>(\d{11}?)<.*?电子邮箱.*?>(.*?)<.*?', re.S) basic = re.search(company, body) if basic: class_url = basic.group(1) zhiwei = basic.group(2) username = basic.group(3) sex_age = basic.group(4).split(',') sex = sex_age[0] age = sex_age[1] address = basic.group(5) mobile = str(basic.group(6)) email = basic.group(7) # print(class_url,zhiwei,username,sex,age,address,mobile,email) html = pq(body) texts = "应聘职位:" + zhiwei + html('body').text() self.setData([ username.strip(), age.strip(), sex.strip(), mobile.strip(), email.strip(), address.strip(), '58', texts.strip(), date, self.local.emailname, class_url ]) except Exception as e: self.showMsg('58同城', e) pass
def resolve_legacyexchangedn_lookup_old(entry, resolve_cache): """ Old method, that looks up a single item entry and adds """ if entry[1] == "EX": legacyExchangeDN = entry[0].lower() if legacyExchangeDN in resolve_cache: return (resolve_cache[legacyExchangeDN], "SMTP") ps_command = ["powershell.exe", "-command"] ps_filter_template = "Get-ADObject -Filter {{legacyExchangeDN -eq '{0}'}} -Properties mail | foreach {{ $_.mail }}" p = subprocess.Popen(ps_command + [ ps_filter_template.format(entry[0]), ], stdout=subprocess.PIPE) email, _ = p.communicate() email = email.strip().lower() resolve_cache[legacyExchangeDN] = email return (email, "SMTP") else: return entry
def upvote(post_id, email=None, user=None): res = {'status': False} p = None try: if email: user = UserProfile.objects.get(email=email) #Email the owner of the post when upvoted email_addr = email.strip() mail = MailResponse(From='no-reply@' + BASE_URL, To=email_addr, Subject="Your Post Has Been Upvoted") #email_user = UserProfile.objects.filter(email=email_addr) message = "Your post %s has been upvoted by %s" % (post_id, user) mail.Html = message logging.debug('TO LIST: ' + str(email_addr)) relay_mailer.deliver(mail, To=[email_addr]) p = Post.objects.get(id=int(post_id)) l = Upvote.objects.get(post=p, user=user) res['status'] = True res['thread_id'] = p.thread.id res['post_name'] = p.subject res['post_id'] = p.id res['group_name'] = p.group.name except UserProfile.DoesNotExist: res['code'] = msg_code['USER_DOES_NOT_EXIST'] % email except Upvote.DoesNotExist: l = Upvote(post=p, user=user) l.save() res['status'] = True res['thread_id'] = p.thread.id res['post_name'] = p.subject res['post_id'] = p.id res['group_name'] = p.group.name except: res['code'] = msg_code['UNKNOWN_ERROR'] logging.debug(res) return res
def upvote(post_id, email=None, user=None): res = {'status':False} p = None try: if email: user = UserProfile.objects.get(email=email) #Email the owner of the post when upvoted email_addr = email.strip() mail = MailResponse(From = 'no-reply@' + BASE_URL, To = email_addr, Subject = "Your Post Has Been Upvoted") #email_user = UserProfile.objects.filter(email=email_addr) message = "Your post %s has been upvoted by %s" % (post_id, user) mail.Html = message logging.debug('TO LIST: ' + str(email_addr)) relay_mailer.deliver(mail, To = [email_addr]) p = Post.objects.get(id=int(post_id)) l = Upvote.objects.get(post=p, user=user) res['status'] = True res['thread_id'] = p.thread.id res['post_name'] = p.subject res['post_id'] = p.id res['group_name'] = p.group.name except UserProfile.DoesNotExist: res['code'] = msg_code['USER_DOES_NOT_EXIST'] % email except Upvote.DoesNotExist: l = Upvote(post=p, user=user) l.save() res['status'] = True res['thread_id'] = p.thread.id res['post_name'] = p.subject res['post_id'] = p.id res['group_name'] = p.group.name except: res['code'] = msg_code['UNKNOWN_ERROR'] logging.debug(res) return res
def add_list(group_name, email, can_receive, can_post, list_url, user): res = {'status' : False } try: group = Group.objects.get(name=group_name) membergroup = MemberGroup.objects.get(group=group, member=user) if membergroup.admin: email = email.strip() list_url = list_url.strip() f = ForwardingList(group=group, email=email, url=list_url, can_receive = can_receive, can_post = can_post) f.save() res['status'] = True else: res['code'] = msg_code['PRIVILEGE_ERROR'] except Group.DoesNotExist: res['code'] = msg_code['GROUP_NOT_FOUND_ERROR'] except MemberGroup.DoesNotExist: res['code'] = msg_code['NOT_MEMBER'] except Exception, e: res['error'] = e
def check_email_valid(self, email): """Check if email is valid. Check @ and . :email str return True/False """ def get_validate_email(email): if not re.match( r"^[A-Za-z0-9\.\+_-]+@[A-Za-z0-9\._-]+\.[a-zA-Z]*$", email): return False return True if not email: return False emails = email.split(',') if len(emails) > 0: for email in emails: if not get_validate_email(email.strip()): return False break return True
def readCsv(name): file = csv.reader(open(name)) ret = {} for row in file: try: email = row[2] name = row[3] trackid = row[6] email = email.strip() name = name.strip() trackid = trackid.strip() if email not in ret: list = [] list.append([name, trackid]) else: list.append([name, trackid]) ret[email] = list except Exception, e: print e.message
def get_admin_emails(self): """ Get the email adresses of all configured admins. Return a list. """ curc, conc = c.connect_to_db(self.coursedb, self.logger_queue, self.name) sql_cmd = "SELECT Content FROM GeneralConfig WHERE ConfigItem == 'admin_email'" curc.execute(sql_cmd) result = curc.fetchone() if result != None: result = str(result[0]) admin_emails = [email.strip() for email in result.split(',')] else: admin_emails = "" conc.close() return admin_emails
def ask_for_email(): email = raw_input('Email address ([email protected]): ') return email.strip()
df_s.head() df_s= df_s.dropna() len(df_s) df_s.To = [sub.replace("frozenset({", "").replace("})","") for sub in df_s.To] df_s.From = [sub.replace("frozenset({", "").replace("})","") for sub in df_s.From] relationship = {} all_pairs = [] for ind in df_s.index: cur_from = df_s['From'][ind] cur_to = df_s['To'][ind].split(",") for email in cur_to: pair = [cur_from] pair.append(email.strip()) pair = [sub.replace("'", "") for sub in pair] # print(pair) all_pairs.append(sorted(pair)) for p in all_pairs: key = '_'.join(p) if key not in relationship: relationship[key] = 0 else: relationship[key] = relationship[key] + 1 BD_rel = {key:value for (key, value) in relationship.items() if value >= 100} BD_rel = dict(sorted(BD_rel.items(), key=operator.itemgetter(1),reverse=True))
def send_email(request): #job_cat_loc = request.POST.get('selected_category_location') #print(job_cat_loc) #job_category = "Python/Django Developer" #job_loc = "San Francisco" #print(job_category, job_loc) print("in send_email") # Get contacts and message from Json file #email_obj = self.json_to_obj(json_file) email = request.POST.get('email_list') print("email:", email) email = "['*****@*****.**','*****@*****.**']" email_list = email.strip('][').replace("'", "").split(",") #email = ["*****@*****.**"] for receiver_email in email_list: subject = "Job Application" body = " " sender_email = "*****@*****.**" # receiver_email = receiver_email # provide sender email pwd password = "******" # Create a multipart message and set headers message = MIMEMultipart() message["From"] = sender_email message["To"] = receiver_email message["Subject"] = subject # message["Bcc"] = receiver_email # Recommended for mass emails text = """\ Hello, \ Applying to job\ Please find the attached resume for your refernece \ Thank You!! """ # Add body to email message.attach(MIMEText(body, "plain")) message.attach(MIMEText(text, "plain")) filename = "C:\\Users\\prade\\PycharmProjects\\ResumeParser_Python_Django_App\\ResumePortal\\media\\Geetha.docx" # In same directory as script # Open PDF file in binary mode with open(filename, "rb") as attachment: # Add file as application/octet-stream # Email client can usually download this automatically as attachment part = MIMEBase("application", "octet-stream") part.set_payload(attachment.read()) # Encode file in ASCII characters to send by email encoders.encode_base64(part) # Add header as key/value pair to attachment part part.add_header( "Content-Disposition", f"attachment; filename= {filename}", ) # Add attachment to message and convert message to string message.attach(part) text = message.as_string() # Log in to server using secure context and send email context = ssl.create_default_context() with smtplib.SMTP_SSL("smtp.gmail.com", 465, context=context) as server: server.login(sender_email, password) server.sendmail(sender_email, receiver_email, text) print("Email sent successfully to ", receiver_email) messages.info(request, "Email successfully sent") """ pandas.set_option('display.max_columns', None) df_from_each_file = (pandas.read_csv(f) for f in li) df_aws = pandas.concat(df_from_each_file, ignore_index=True) print(df_aws.shape) print(df_aws.columns) """ #job_list(request,job_category,job_loc) return render(request, 'resumeapp/Job_Search.html')
def clean_email(email): return email.strip('<>').lower()