当前位置:网站首页>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 ")
边栏推荐
- Post infiltration flow encryption
- 跨域?同源?一次搞懂什么是跨域
- Ks006 student achievement management system based on SSM
- 【毕业季】研究生学长分享怎样让本科更有意义
- leetcode2305. 公平分发饼干(中等,周赛,状压dp)
- D discard the virtual recovery method
- This is the report that leaders like! Learn dynamic visual charts, promotion and salary increase are indispensable
- Based on configured schedule, the given trigger will never fire
- new和malloc的区别
- Types of exhibition items available in the multimedia interactive exhibition hall
猜你喜欢

Opengauss database backup and recovery guide

Pytest testing framework

leetcode2311. Longest binary subsequence less than or equal to K (medium, weekly)

PR second training

【视频】马尔可夫链蒙特卡罗方法MCMC原理与R语言实现|数据分享

734. Energy stone (greed, backpack)

分卷压缩,解压

With the innovation and upgrading of development tools, Kunpeng promotes the "bamboo forest" growth of the computing industry

Word search applet design report based on cloud development +ppt+ project source code + demonstration video

医药管理系统(大一下C语言课设)
随机推荐
Ubuntu20.04 PostgreSQL 14 installation configuration record
Is the knowledge of University useless and outdated?
Electronic Association C language level 1 33, odd even number judgment
leetcode2311. Longest binary subsequence less than or equal to K (medium, weekly)
321. Chessboard segmentation (2D interval DP)
【深度学习】infomap 人脸聚类 facecluster
Bash bounce shell encoding
1069. Division of convex polygons (thinking, interval DP)
Types of exhibition items available in the multimedia interactive exhibition hall
Logging only errors to the console Set system property ‘log4j2. debug‘ to sh
leetcode2312. Selling wood blocks (difficult, weekly race)
How to build and use redis environment
2022 Q2 - 提升技能的技巧总结
golang---锁
The concept, function, characteristics, creation and deletion of MySQL constraints
1222. Password dropping (interval DP, bracket matching)
Software No.1
Which is a good Bluetooth headset of about 300? 2022 high cost performance Bluetooth headset inventory
Pytest testing framework
[C #] use regular verification content