[Python] Send email

Create an email sending script

mail.py


from email.mime.text import MIMEText
import smtplib

#SMTP authentication information
account = "example.com"
password = "XXXXXXXX"
 
#Send / receive destination
to_email = "[email protected]"
from_email = "[email protected]"
 
#Create MIME
subject = "Test title"
message = "Test body"
msg = MIMEText(message, "html")
msg["Subject"] = subject
msg["To"] = to_email
msg["From"] = from_email
 
#Email sending process
server = smtplib.SMTP("example.com", 587)
server.starttls()
server.login(account, password)
server.send_message(msg)
server.quit()

Run

python mail.py

Recommended Posts

[Python] Send email
[Python] Send email
Send email with Python
Send Japanese email with Python3
Send email in Python (Outlook)
Python 3.6 email library
[Python] Send an email with outlook
Send email via gmail with Python 3.4.3.
Send email to multiple recipients in Python (Python 3)
Send an email with Amazon SES + Python
Send email with Django
Validate E-Mail with Python
Send Gmail in Python
Send an email with Excel attached in Python
Python
Send email using Python's smtplib
Send using Python with Gmail
[Python] Send an email from gmail with two-step verification set
[boto3] Send an email using SES
Easy email sending with haste python3
Note: Send an email with Django
Send multipart / form-data with python requests
Send image with python, save with php
[Python] Create API to send Gmail
kafka python
Python basics ⑤
python + lottery 6
Python Summary
Built-in python
Python technique
Studying python
Python 2.7 Countdown
Python memorandum
python tips
python function ①
Python basics
Python memo
ufo-> python (3)
install python
Python Singleton
Python basics ④
Python Memorandum 2
python memo
Python Jinja2
Python increment
atCoder 173 Python
Send an email to a specific email address with python without SMTP settings
[Python] function
Send a message from Python to Slack
Python installation
python tips
Installing Python 3.4.3.
Send email with SES in Python and short message with SMS on SNS
Try python
Python iterative
Python algorithm
Python2 + word2vec
[Python] Variables
Python functions
Python sys.intern ()
Python tutorial