def _send_email_passchange(user): registration_uuid = str(uuid.uuid4()) registration_uuid = registration_uuid + str(uuid.uuid4()) ChangePasswordRequest.objects.create(user_pk=user.pk, user_token = registration_uuid) g = gmail.GMail('*****@*****.**', '123456789qQ') msg = gmail.Message('Herdius ICO Password changing', to = user.email, html=html1.replace('myhref', 'http://www.opnplatform.io/development/changepass/' + str(registration_uuid))) g.send(msg)
def send_mail(base_mail, to_mail, user_name, user_text): # try: b = "".join(["Thanks 2018! <", base_mail, ">"]) gm = gmail.GMail(b, 'sonic1980') msg = Message('Спасибо от', to="me <{0}>".format(to_mail), text="Спасибо от {0}, сообщение: {1}".format( user_name, user_text)) gm.send(msg) # except Exception as ex: # pass # def send_mail_key(base_mail, base_mailpass, to_mail, akey): # # b = "".join(["sharkevo <", base_mail, ">"]) # txt = "".join(["Для завершения регистрации и начала работы ", # "введите указанный код активации на сайте: ", # akey]) # # gm = gmail.GMail(b, base_mailpass) # msg = Message('Завершение регистрации', to="me <{0}>".format(to_mail), text=txt) # gm.send(msg) "tgxm8ou"
def run_job(): date = datetime.now() sub_folder = str(date.hour) s3_folder = '{0}-{1}-{2}/{3}/'.format(str(date.year), str(date.month), str(date.day), sub_folder) email_config = json.load(open('config/email.json')) account = gmail.GMail(email_config['sender_email'], email_config['sender_pass']) hours_to_pull = '24' try: subprocess.check_output(['python', '-m', 'scripts.radian6', '--hours', hours_to_pull, s3_folder]) result = subprocess.check_output(['python', '-m', 'scripts.post_prepper', '{0}'.format(s3_folder)]) email_message = (''' The Radian6 to Salesforce export/import ran with the following results: {0} ''').format(result) msg = gmail.Message('Radian6 to Salesforce results', to=', '.join(email_config['recipients']), text=email_message) account.send(msg) print(result) except subprocess.CalledProcessError as e: #e = sys.exc_info()[0] email_message = (''' An error occurred while processing Radian6 to Salesforce export/import: {0} ''').format(str(e.output)) msg = gmail.Message('ERROR: Radian6 to Salesforce', to=', '.join(email_config['recipients']), text=email_message) account.send(msg) raise
def mailQr(self, EMAIL, KODEDOSEN): gm = gmail.GMail(config.email, config.password) isipesan = config.msg.replace("KODEDOSEN", KODEDOSEN) msg = message.Message(config.subject, to=EMAIL, text=isipesan, attachments=['qr.jpg']) gm.send(msg)
def sendGmail(u, p, t, s, b, a): #u=user,p=pass,t=to_addr,s=subject,b=body,a=attachment client = gmail.GMail(u, p) if a == '': message = gmail.Message(s, to=t, text=b) else: message = gmail.Message(s, to=t, text=b, attachments=[a]) client.send(message) client.close()
def main(): #アカウント名 username = '******' + "@gmail.com" #パスワード password = '******' client = gmail.GMail(username,password) #メッセージ内容 message = gmail.Message(u'サブジェクト : HellWorld', to = username , text = u'ボディ : これはテストケース注意されたし!!' ) client.send(message) client.close() return 0
def do_send(program): client = gmail.GMail(user_name, password) message = gmail.Message(u'サブジェクト:こんにちは世界', to=user_name, text=u'ボディ:これはテストメッセージです') try: # client.send(message) print('test') except Exception as e: raise e client.close() return True
def main(): srv = gmail.GMail('Username do Gmail', 'Senha do Gmail') att1 = 'nome do anexo(opcional) ou caminho do anexo' exist = os.path.exists(att1) # verifica se o anexo existe (opcional); if exist == False: #anexo não existe; warning = gmail.Message('Título do e-mail', to='*****@*****.**', text='Texto do e-mail') srv.send(warning) else: #anexo existe; msg = gmail.Message('Título do e-mail', to='*****@*****.**', text='Texto do e-mail', attachments=[att1]) srv.send(msg) delArchive() #procedimento para deletar o anexo(opcional);
def send_gmail(subject, body, address, message_mode='text'): must_have_keys = set(['email_username', 'email_password', 'email_from']) conf = get_conf() my_gmail = gmail.GMail(conf.email_username, conf.email_password) if message_mode == 'html': msg = gmail.Message(subject, html=body, to=address, sender=conf.email_from) else: msg = gmail.Message(subject, text=body, to=address, sender=conf.email_from) try: my_gmail.send(msg) except gmail.gmail.SMTPAuthenticationError as e: print e.smtp_error return False return True
def send_mail(body, attachment=''): address = '*****@*****.**' sender_address = '*****@*****.**' SENDER_NAME = '渡邊 由彦' username = '******' password = '' # Need the real password here client = gmail.GMail(username, password) finished = datetime.datetime.now() finished_f = finished.strftime("%Y/%m/%d %H:%M:%S") if attachment == '': message = gmail.Message(u'BSニュースTweet ' + finished_f, to=address, text=body) else: message = gmail.Message(u'BSニュースTweet ' + finished_f, to=address, text=body, attachments=[attachment]) client.send(message) client.close() return
def send_gmain(): msgs = loadProperties() # Gmailアカウント情報 sendUsername = msgs['from'] #'*****@*****.**' sendUserPassword = msgs['mailpass'] #'from_user_password' # メール送信パラメータ subject = msgs['subject'] toAddr = msgs['to'] #'*****@*****.**' cc = msgs['cc'] #'*****@*****.**' body = loadBody() #print(msgs) # メールサーバに接続して、ログインとメール送信 try: print('メール送信開始') # Gmailへのログインとメール送信 client = gmail.GMail(sendUsername, sendUserPassword) message = gmail.Message(subject=subject, to=toAddr, cc=cc, text=body) client.send(message) client.close() print('メール送信完了!') except Exception as e: # メール送信エラー時の対処 try: client.close() except: print('メール送信エラーです。') return -1 now_date = str(datetime.datetime.now()) writeHistory('[ERROR] : ' + now_date + ' : メール送信に失敗しました\n') writeHistory(' ' + str(e) + '\n') print('メール送信エラーです。') return -1 return 0
def sendImageByGmail(subject, body, image): if (settings.SEND_EMAIL is not True): return user = settings.GMAIL_USER password = settings.GMAIL_PASS client = gmail.GMail(user, password) to = settings.GMAIL_TO subject = "[facesesame] " + subject if image == '': message = gmail.Message(subject, to=to, text=body) else: attachment = MIMEImage(image, 'jpeg', filename="file.jpg") attachment.add_header('Content-Disposition', "attachment; filename=file.jpg") message = gmail.Message(subject, to=to, text=body, attachments=[attachment]) client.send(message) client.close()
def __init__(self, user, password): # sender class self.sender = gmail.GMail(user, password)
def _send_email(user): registration_uuid = uuid.uuid4() RegistrationRequest.objects.create(user_pk=user.pk, user_registration_uuid = registration_uuid) g = gmail.GMail('*****@*****.**', '123456789qQ') msg = gmail.Message('Herdius ICO Registration', to = user.email, html=html.replace('myhref', 'http://www.opnplatform.io/development/activate/' + str(registration_uuid))) g.send(msg)
def __init__(self, mail_account=PROXY_MAIL, mail_password=MAIL_PASSWORD): self._api = gmail.GMail(mail_account, mail_password)
number_of_new_items = number_of_new_items + 1 price = get_price(item) local = get_location(item) name = get_post_name(item) link = get_post_link(item) post_time = get_post_time(item) body = "Name: {0}\nPrice: {1}\nLocation: {2}\nPosted: {3}\nLink: {4}".format( name, price, local, post_time, link) # Read in uname/pword here so that it's not in memory creds_file = open('arcf/.creds_file.txt', 'r') uname = creds_file.readline().strip() pword = creds_file.readline().strip() creds_file.close() gm = gmail.GMail(uname, pword) uname = None pword = None gm.connect() try: msg = gmail.Message( 'New {} Found on Craigslist'.format( thing.strip().upper()), to='*****@*****.**', text=body) gm.send(msg) postings.append(pid) # Update our list existing_item_list_file = open("list_file.txt", 'w')
def __init__(self): self.gm = gmail.GMail(uname, password) self.gm.connect()
# coding: utf-8 import gmail # Login to Gmail settings GMAIL_USER = '******' GMAIL_PASS = '******' # Mail parameter TOADDR = '(slackbot)@(your workspace).slack.com)' subject = '日本語' # Japanese body = 'メッセージ\n改行も' # Message, and new line message = gmail.Message(subject, to=TOADDR, text=body) # send mail client = gmail.GMail(GMAIL_USER, GMAIL_PASS) client.send(message) client.close()
import smtplib import email import pickle #Read write functions def write_results(link_list): with open('links.p','wb') as f: pickle.dump(link_list,f) def read_results(): data = pickle.load(open('links.p', 'rb')) return data #add email to send from here, use a junk one gm = gmail.GMail('*****@*****.**', '123456789') gm.connect() # This will remove weird characters that people put in titles like ****!***!!! use_chars = string.ascii_letters + ''.join([str(i) for i in range(10)]) + ' ' link_list = [] # We'll store the data here link_list_send = [] # This is a list of links to be sent send_list = [] # This is what will actually be sent in the email # Define our URL and a query we want to post base_url = 'http://sfbay.craigslist.org/search/eby/apa/' find_url = 'http://sfbay.craigslist.org' link_list = read_results()
# Select Inbox to perform search operation M.select('"INBOX"') # Search emails with a given subject typ, data = M.search(None, 'SUBJECT', '"Email with an attachment"') # Fetch Email message and print if len(data[0]) > 0: typs, msg = M.fetch(data[0].split('-')[-1], '(RFC822)') print("Message is ", msg[0][1]) M.close() # Logout from gmail account M.logout() import gmail, config from datetime import date # Login to gmail account g = gmail.GMail(config.fromaddr, config.password) # Search for emails after July 22nd and fetch the first email mails = g.inbox().mail(after=date(2016, 7, 22)) mails[-1].fetch() # Get body of the fetched email print("Email Body:\n", mails[-1].body) # Logout of email account g.logout()
try: print('メール送信開始') # ユーザ名とパスワードの入力 print('MailAccount: ', end=' ') sendUsername = input() sendUserPassword = getpass.getpass() # 受信者アドレスの入力 print('宛先アドレス: ', end=' ') toAddr = input() # 件名と本文の入力 print('件名: ', end=' ') subject = input() print('メール本文: ', end=' ') body = input() # Gmailへのログインとメール送信 client = gmail.GMail(sendUsername, sendUserPassword) message = gmail.Message(subject=subject, to=toAddr, text=body) client.send(message) client.close() print('メール送信完了!') except: # メール送信エラー時の対処 try: client.close() except: pass print('メール送信エラーです。')
def gmailSend(self, msg, address): self.gm = gmail.GMail(uname, password) self.gm.connect() self.gm.send(msg, [address])
#20 # Finally, we can save this data to a CSV to play around with it later. # We'll have to remove some annoying characters first: import string use_chars = string.ascii_letters +\ ''.join([str(i) for i in range(10)]) +\ ' /\.' results['title'] = results['title'].apply( lambda a: ''.join([i for i in a if i in use_chars])) results.to_csv('../data/craigslist_results.csv') #Bonus # We'll use the gmail module (there really is a module for everything in python) import gmail import time gm = gmail.GMail('my_username', 'my_password') gm.connect() # Define our URL and a query we want to post base_url = 'http://sfbay.craigslist.org/' url = base_url + 'search/eby/apa?nh=48&anh=49&nh=112&nh=58&nh=61&nh=62&nh=66&max_price=2200&bedrooms=1' # This will remove weird characters that people put in titles like ****!***!!! use_chars = string.ascii_letters + ''.join([str(i) for i in range(10)]) + ' ' link_list = [] # We'll store the data here link_list_send = [] # This is a list of links to be sent send_list = [] # This is what will actually be sent in the email # Careful with this...too many queries == your IP gets banned temporarily while True: resp = requests.get(url)