Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python imaplib send email

import smtplib

def prompt(prompt):
    return input(prompt).strip()

fromaddr = prompt("From: ")
toaddrs  = prompt("To: ").split()
print("Enter message, end with ^D (Unix) or ^Z (Windows):")

# Add the From: and To: headers at the start!
msg = ("From: %s
To: %s

"
       % (fromaddr, ", ".join(toaddrs)))
while True:
    try:
        line = input()
    except EOFError:
        break
    if not line:
        break
    msg = msg + line

print("Message length is", len(msg))

server = smtplib.SMTP('localhost')
server.set_debuglevel(1)
server.sendmail(fromaddr, toaddrs, msg)
server.quit()
Comment

PREVIOUS NEXT
Code Example
Python :: python remove many items via index at oncefrom a list? 
Python :: python split input to list 
Python :: Sum items in a list with ints and strings in python 
Python :: python dictionary append value if key exists 
Python :: python str contains word 
Python :: get current function name in python3 
Python :: pd dataframe single column rename 
Python :: pandas eliminar filas de un dataframe con una condicion 
Python :: python how to see what pip packages are installed 
Python :: trim string python 
Python :: if string is in array python 
Python :: circumference of a circle python 
Python :: python json random number generator 
Python :: drop first column read_csv 
Python :: pandas cartesian product 
Python :: merge all mp4 video files into one file python 
Python :: python logging basicConfig+time 
Python :: sharpdevelop pause python code 
Python :: python save to excel 
Python :: how to get a int from string python 
Python :: mean squared error 
Python :: Week of the year Pandas 
Python :: python convert two dimensional list to one dimensional 
Python :: get local ip 
Python :: concatenating datfra,esin pandas 
Python :: python yeild 
Python :: python possible combinations 
Python :: Setting up Colab for Kaggle Downloads 
Python :: SciPy Convex Hull 
Python :: at=error code=h10 desc= app crashed python flask 
ADD CONTENT
Topic
Content
Source link
Name
4+2 =