当前位置:网站首页>Email picture attachment
Email picture attachment
2022-07-02 02:05:00 【Operation and maintenance dumplings】
Free email smtp There is a size limit for sending attachment files , Generally, you can only send dozens M, If you are older, you need to spend money to open big file transfer .
# -*- coding: UTF-8 -*-
import os
import smtplib
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
from email.utils import formataddr
from time import sleep
# from email.header import Header
def sent_mes(path, name):
# Structural annex 1, delivery path file
att1 = MIMEText(open(path, 'rb').read(), 'base64', 'utf-8')
att1["Content-Type"] = 'application/octet-stream'
# there filename You can write whatever you want , What's the name , What's the name in the email
att1["Content-Disposition"] = f'attachment; filename= {
name}'
message.attach(att1)
# sender = "[email protected]"
# password = 'DQYMSQRHJEOCRR'
# smtpserver = 'smtp.126.com' 465
mail_host = 'smtp.126.com'
mail_port = 465
mail_user = '[email protected]'
mail_passwd = 'DQYMSJEXSOCRR'
sender = '[email protected]'
receivers = '[email protected]'
message = MIMEMultipart()
message['From'] = formataddr(['lg', sender])
message['To'] = formataddr([' Hebei Province ', receivers])
message['Subject'] = 'naq And meteorological pictures '
message.attach(MIMEText(' This is a picture email ','plain', 'utf-8'))
sent_mes('/root/ou_zhou.zip','ou_zhou.zip')
sent_mes('/root/han_guo.zip','han_guo.zip')
#sent_mes('/root/NAQPMS.zip','NAQPMS.zip')
smtp = smtplib.SMTP_SSL(mail_host,mail_port)
smtp.login(mail_user, mail_passwd)
print(" Send successfully ")
smtp.sendmail(sender,receivers,message.as_string())
# print(" Send successfully ")
边栏推荐
- The role of artificial intelligence in network security
- Construction and maintenance of business websites [11]
- Based on configured schedule, the given trigger will never fire
- What is the MySQL column to row function
- [deep learning] Infomap face clustering facecluster
- Matlab uses resample to complete resampling
- 【视频】马尔可夫链蒙特卡罗方法MCMC原理与R语言实现|数据分享
- Construction and maintenance of business websites [13]
- 剑指 Offer 62. 圆圈中最后剩下的数字
- How to use redis ordered collection
猜你喜欢

Types of exhibition items available in the multimedia interactive exhibition hall

MySQL view concept, create view, view, modify view, delete view

WebGPU(一):基本概念

Spend a week painstakingly sorting out the interview questions and answers of high-frequency software testing / automated testing

Medical management system (C language course for freshmen)

leetcode2309. 兼具大小写的最好英文字母(简单,周赛)

【LeetCode 43】236. The nearest common ancestor of binary tree

花一个星期时间呕心沥血整理出高频软件测试/自动化测试面试题和答案

How does MySQL solve the problem of not releasing space after deleting a large amount of data

医药管理系统(大一下C语言课设)
随机推荐
Golang lock
Post infiltration flow encryption
The concepts and differences between MySQL stored procedures and stored functions, as well as how to create them, the role of delimiter, the viewing, modification, deletion of stored procedures and fu
leetcode2309. The best English letters with both upper and lower case (simple, weekly)
How to execute an SQL in MySQL
Sword finger offer 42 Maximum sum of continuous subarrays
城市选择器组件实现原理
What are the necessary things for students to start school? Ranking list of Bluetooth headsets with good sound quality
How to use a product to promote "brand thrill"?
From January 11, 2007 to January 11, 2022, I have been in SAP Chengdu Research Institute for 15 years
Number of palindromes in C language (leetcode)
[graduation season] graduate seniors share how to make undergraduate more meaningful
剑指 Offer 62. 圆圈中最后剩下的数字
What are the skills of spot gold analysis?
* and & symbols in C language
The difference between new and malloc
Should enterprises choose server free computing?
leetcode2311. Longest binary subsequence less than or equal to K (medium, weekly)
花一个星期时间呕心沥血整理出高频软件测试/自动化测试面试题和答案
There are spaces in the for loop variable in the shell -- IFS variable