A program that sends a fixed amount of mail at a specified time by Python

Import the module.

import datetime import smtplib import ssl from email.mime.text import MIMEText import sys, codecs

sys.stdout = codecs.getwriter("utf-8")(sys.stdout) gmail_account = "" # → Please enter your email address. gmail_password = "" # → Please enter your e-mail address and password. gmail to = "" # → Please enter the email address you want to send. send_name = "Pooyan"

Decide how long you want to send an email.

today_date = datetime.date.today() delivery_date = today_date + datetime.timedelta(days=7) print(today_date,delivery_date)

Creating mail data (MIME)

subject = "{0}, we will send you a purchase order for {1}.". Format (send_name, today_date) body = "We will send you the purchase order with the title.
Please check the attached file.
The delivery date for this order will be {0}.

Puyan Co., Ltd.". Format (delivery_date )

print (subject) # For confirmation

print (body) #for confirmation

msg = MIMEText(body, "html") print(msg)

msg["Subject"] = subject msg["To"] = mail_to msg["From "] = gmail_account print(msg)

server = smtplib.SMTP_SSL("smtp.gmail.com", 465,context=ssl.create_default_context()) server.login(gmail_account, gmail_password) server.send_message(msg) server.close() print ('send completed')

Recommended Posts

A program that sends a fixed amount of mail at a specified time by Python
[Python] A program that finds a pair that can be divided by a specified value
[Python] A program that counts the number of valleys
[Python] A program that compares the positions of kangaroos.
A Python program that aggregates time usage from icalendar data
How to start the PC at a fixed time every morning and execute the python program
A function that measures the processing time of a method in python
The story of making a module that skips mail with python
[Python] A program that rotates the contents of the list to the left
[Python] A program that compares each element of list one by one and wins or loses. zip ()
[Python] A program that creates stairs with #
[Python] A program that calculates the number of chocolate segments that meet the conditions
[Python] A program that calculates the number of socks to be paired
Get a datetime instance at any time of the day in Python
A program that plays rock-paper-scissors using Python
[Python] A program that rounds the score
I made a program in Python that reads CSV data of FX and creates a large amount of chart images
Get Unix time of the time specified by JST regardless of the time zone of the server in Python
Publishing and using a program that automatically collects facial images of specified people
A set of integers that satisfies ax + by = 1.
A program that removes duplicate statements in Python
A memorandum of extraction by python bs4 request
At the time of python update on ubuntu
A python script that gets the number of jobs for a specified condition from indeed.com
[Python] A program that finds the shortest number of steps in a game that crosses clouds
A program that summarizes the transaction history csv data of SBI SECURITIES stocks [Python3]
I made a program in Python that changes the 1-minute data of FX to an arbitrary time frame (1 hour frame, etc.)
Python that merges a lot of excel into one excel
Created a Python library DateTimeRange that handles time ranges
A shell program that becomes aho in multiples of 3
I created a Discord bot on Docker that reports the number of corona infected people in Tokyo at a specified time.
Example of how to aggregate a large amount of time series data using Python at a reasonable speed in a small memory environment
Tasks at the start of a new python project
Group by consecutive elements of a list in Python
A Python program that converts ical data into text
A library that monitors the life and death of other machines by pinging from Python
Summary of points to keep in mind when writing a program that runs on Python 2.5
[Python] Programming to find the number of a in a character string that repeats a specified number of times.
[Python] A program to find the number of apples and oranges that can be harvested
A Python program in "A book that gently teaches difficult programming"
A general-purpose program that formats Linux command strings in python
Give a Python decorator an alias that passes fixed arguments
[Python] How to make a list of character strings character by character
How to shuffle a part of a Python list (at random.shuffle)
Grep so that grep does not appear at the time of grep
[Python] A program that finds the most common bird types
Construction of a neural network that reproduces XOR by Z3
A set of script files that do wordcloud in Python3
A Python script that compares the contents of two directories
[Python] A program that finds the maximum number of toys that can be purchased with your money
・ <Slack> Write a function to notify Slack so that it can be quoted at any time (Python)