当前位置:网站首页>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 ")
边栏推荐
- Three core problems of concurrent programming
- Six lessons to be learned for the successful implementation of edge coding
- leetcode2311. 小于等于 K 的最长二进制子序列(中等,周赛)
- [graduation season] graduate seniors share how to make undergraduate more meaningful
- 城市选择器组件实现原理
- 牛客网——华为题库(51~60)
- D discard the virtual recovery method
- 如何远程、在线调试app?
- An analysis of circuit for quick understanding
- golang---锁
猜你喜欢
WebGPU(一):基本概念
How to solve MySQL master-slave delay problem
leetcode2311. Longest binary subsequence less than or equal to K (medium, weekly)
The concept, function, characteristics, creation and deletion of MySQL constraints
Medical management system (C language course for freshmen)
An analysis of circuit for quick understanding
Pytest testing framework
This is the form of the K-line diagram (pithy formula)
734. Energy stone (greed, backpack)
Word search applet design report based on cloud development +ppt+ project source code + demonstration video
随机推荐
如何用一款产品推动「品牌的惊险一跃」?
VARIATIONAL IMAGE COMPRESSION WITH A SCALE HYPERPRIOR文献实验复现
剑指 Offer 47. 礼物的最大价值
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
MySQL如何解决delete大量数据后空间不释放的问题
[Video] Markov chain Monte Carlo method MCMC principle and R language implementation | data sharing
The concept, function, characteristics, creation and deletion of MySQL constraints
Volume compression, decompression
【视频】马尔可夫链蒙特卡罗方法MCMC原理与R语言实现|数据分享
Software No.1
Deep learning: a solution to over fitting in deep neural networks
JMeter (I) - download, installation and plug-in management
leetcode2310. 个位数字为 K 的整数之和(中等,周赛)
leetcode2309. The best English letters with both upper and lower case (simple, weekly)
MySQL约束与多表查询实例分析
Construction and maintenance of business websites [10]
leetcode373. Find and minimum k-pair numbers (medium)
How to turn off debug information in rtl8189fs
Ks006 student achievement management system based on SSM
Exception handling of class C in yyds dry goods inventory