import smtplib
with smtplib.SMTP('smtp.gmail.com',587) as smtp:
smtp.starttls()
smtp.login("dibaloke66@gmail.com","password")
subject="Test for sending a email via python for measurment project"
body=" Alert ! Security system activated in your Smart home"
msg=f'Subject: {subject} \n \n {body}'
smtp.sendmail("dibaloke66@gmail.com","dibaloke66@gmail.com",msg)
import smtplib
with smtplib.SMTP_SSL('smtp.gmail.com',465) as smtp:
smtp.login("dibaloke66@gmail.com","password")
subject="Test for sending a email via python for measurment project"
body=" Alert ! Security system activated in your Smart home"
msg=f'Subject: {subject}\n \n{body}'
smtp.sendmail("dibaloke66@gmail.com","dibaloke66@gmail.com",msg)
import smtplib
from email.message import EmailMessage
msg=EmailMessage()
msg['Subject']='Test for sending a email via python for measurment project'
msg['From']='dibaloke66@gmail.com'
msg['To']='dibaloke66@gmail.com'
msg.set_content('Alert ! Security system activated in your Smart home')
with smtplib.SMTP_SSL('smtp.gmail.com',465) as smtp:
smtp.login("dibaloke66@gmail.com","password")
smtp.send_message(msg)
import smtplib
import imghdr
from email.message import EmailMessage
msg=EmailMessage()
msg['Subject']='Test for sending a email via python for measurment project'
msg['From']='dibaloke66@gmail.com'
msg['To']='dibaloke66@gmail.com'
msg.set_content('Alert ! Security system activated in your Smart home')
//make sure the image exists at root of your project
with open('medical-cyber-security-breaches.jpg','rb') as f:
file_data = f.read()
file_type = imghdr.what(f.name)
file_name = f.name
# print(file_type)
msg.add_attachment(file_data,maintype='image',subtype=file_type,filename=file_name)
with smtplib.SMTP_SSL('smtp.gmail.com',465) as smtp:
smtp.login("dibaloke66@gmail.com","password")
smtp.send_message(msg)
import smtplib
import imghdr
from email.message import EmailMessage
msg=EmailMessage()
msg['Subject']='Test for sending a email via python for measurment project'
msg['From']='dibaloke66@gmail.com'
msg['To']='dibaloke66@gmail.com'
msg.set_content('Alert ! Security system activated in your Smart home')
files=['img_1.jpg','img_2.jpg']
for file in files:
with open(file,'rb') as f:
file_data = f.read()
file_type = imghdr.what(f.name)
file_name = f.name
# print(file_type)
msg.add_attachment(file_data,maintype='image',subtype=file_type,filename=file_name)
with smtplib.SMTP_SSL('smtp.gmail.com',465) as smtp:
smtp.login("dibaloke66@gmail.com","password")
smtp.send_message(msg)
import smtplib
import imghdr
from email.message import EmailMessage
msg=EmailMessage()
msg['Subject']='Test for sending a email via python for measurment project'
msg['From']='dibaloke66@gmail.com'
msg['To']='dibaloke66@gmail.com'
msg.set_content('Alert ! Security system activated in your Smart home')
files=['resume.pdf']
for file in files:
with open(file,'rb') as f:
file_data = f.read()
file_name = f.name
# print(file_type)
msg.add_attachment(file_data,maintype='application',subtype='octet-stream',filename=file_name)
with smtplib.SMTP_SSL('smtp.gmail.com',465) as smtp:
smtp.login("dibaloke66@gmail.com","password")
smtp.send_message(msg)
import smtplib
import imghdr
from email.message import EmailMessage
contacts=['dibaloke66@gmail.com','a@gmail.com','b@gmail.com']
msg=EmailMessage()
msg['Subject']='Test for sending a email via python for measurment project'
msg['From']='dibaloke66@gmail.com'
msg['To']=contacts
msg.set_content('Alert ! Security system activated in your Smart home')
files=['resume.pdf']
for file in files:
with open(file,'rb') as f:
file_data = f.read()
file_name = f.name
# print(file_type)
msg.add_attachment(file_data,maintype='application',subtype='octet-stream',filename=file_name)
with smtplib.SMTP_SSL('smtp.gmail.com',465) as smtp:
smtp.login("dibaloke66@gmail.com","password")
smtp.send_message(msg)
import smtplib
import imghdr
from email.message import EmailMessage
msg=EmailMessage()
msg['Subject']='Test for sending a email via python for measurment project'
msg['From']='dibaloke66@gmail.com'
msg['To']='dibaloke66@gmail.com'
msg.set_content('Alert ! Security system activated in your Smart home')
msg.add_alternative("""\
<!DOCTYPE html>
<html>
<body>
<h1 style="color:SlateGray;">This is an HTML Email!</h1>
</body>
</html>
""",subtype='html')
with smtplib.SMTP_SSL('smtp.gmail.com',465) as smtp:
smtp.login("dibaloke66@gmail.com","password")
smtp.send_message(msg)