Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python send email from icloud

port = 587
smtp_server = 'smtp.mail.me.com'
sender_email = 'sender@icloud.com'
recipient_email = 'recipient@icloud.com'
password = 'app-specific-password' # For more on this: https://support.apple.com/en-gb/HT204397#:~:text=App%2Dspecific%20passwords%20are%20passwords,services%20not%20provided%20by%20Apple.

subject = 'Test'
# The message must have the sender and recipient email in
message = f'From: {sender_email}
To: {recipient_email}
Subject: {subject}
 This is a test'

# IF the following line doesn't work
context = ssl.create_default_context()
# Use:
context = ssl._create_unverified_context()

with smtplib.SMTP(smtp_server, port) as server:
    try: 
        server.ehlo()
        server.starttls(context=context)
        server.ehlo()
        server.login(sender_email, password)
        server.sendmail(
            sender_email, 
            recipient_email,
            message)
        print('email sent!')
    except:
        print('email did not send')
Comment

PREVIOUS NEXT
Code Example
Python :: python select from list by boolean list 
Python :: destructuring in for loops python 
Python :: k fold cross validation xgboost python 
Python :: combinations 
Python :: # convert string to date 
Python :: get diagonals of 2d array 
Python :: gui def python 
Python :: python django adding category 
Python :: numpy filter based on value 
Python :: Adding two lists using map() and Lamda Function 
Python :: Python Print Variable Using the f-string in the print statement 
Python :: python system performance 
Python :: how to install pywhatkit in pycharm 
Python :: turn off yticklabels 
Python :: python split string on char 
Python :: gene wilder pure imagination 
Python :: check if binary tree is balanced python 
Python :: pandas get highest values column 
Python :: python linear search 
Python :: convert timestamp to period pandas 
Python :: pandas print column by index 
Python :: setup mongodb database with django 
Python :: python calculate the power of number 
Python :: python sh command 
Python :: how to iterate a list in reverse order in python with index 
Python :: Python program to read a random line from a file 
Python :: django form action 
Python :: datetime64 ns to date python 
Python :: requirements.txt dev python 
Python :: remove element from pack tkinter 
ADD CONTENT
Topic
Content
Source link
Name
4+2 =