Search
 
SCRIPT & CODE EXAMPLE
 

HTML

Send an email

import smtplib
from email.mime.text import MIMEText
from email.utils import formatdate

FROM_ADDRESS = 'your-email@email-client.com'
TO_ADDRESS = 'recipent@email-client.com'
SUBJECT = 'test mail'
BODY = 'send mail by python'
SMTP_SERVER = 'smtp-mail.outlook.com' # may need to change

def create_message(from_addr, to_addr, subject, body):
    msg = MIMEText(body)
    msg['Subject'] = subject
    msg['From'] = from_addr
    msg['To'] = to_addr
    msg['Date'] = formatdate()
    return msg


def send(from_addr, to_addrs, msg):
    smtpobj = smtplib.SMTP(SMTP_SERVER, 25)
    smtpobj.ehlo()
    smtpobj.starttls()
    smtpobj.sendmail(from_addr, to_addrs, msg.as_string())
    smtpobj.close()


if __name__ == '__main__':

    to_addr = TO_ADDRESS
    subject = SUBJECT
    body = BODY

    msg = create_message(FROM_ADDRESS, to_addr, subject, body)
    send(FROM_ADDRESS, to_addr, msg)
Comment

PREVIOUS NEXT
Code Example
Html :: html favicon.ico 
Html :: add google search bar to our website in html 
Html :: how to center link in html 
Html :: regex to remove html tags python 
Html :: how to change the logo in the title of a webpage 
Html :: how to add a logo icon in HTML 
Html :: sample html file 
Html :: bootstrap height 100vh class 
Html :: font awesome 
Html :: share to twitter html link 
Html :: how to add a browser tab icon 
Html :: font awesome 5 pro 
Html :: image src on error 
Html :: target blank 
Html :: buton html href 
Html :: jquery select2 set value 
Html :: how to give color to text in html 
Html :: ngfor with index 
Html :: web mdc cdn 
Html :: tailwind push footer always to bottom of screen 
Html :: dynamic colspan in angular 
Html :: target blank html 
Html :: font awesome facebook icon 
Html :: accept only numbers in textbox 
Html :: copyright sign in html 
Html :: html make space between buttons 
Html :: html table cell border not showing 
Html :: how to check where was the changes in a perticuler commit git 
Html :: html escape characters 
Html :: show location on google map using latitude and longitude web html 
ADD CONTENT
Topic
Content
Source link
Name
9+8 =