当前位置:网站首页>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 ")
边栏推荐
- 跨域?同源?一次搞懂什么是跨域
- MySQL中一条SQL是怎么执行的
- Exception handling of class C in yyds dry goods inventory
- 分卷压缩,解压
- Pytest testing framework
- An analysis of circuit for quick understanding
- CSDN article underlined, font color changed, picture centered, 1 second to understand
- Construction and maintenance of business websites [15]
- np.where 和 torch.where 用法
- 正则表达式学习笔记
猜你喜欢
剑指 Offer 62. 圆圈中最后剩下的数字
Should enterprises choose server free computing?
MySQL constraints and multi table query example analysis
JPM 2021 most popular paper released (with download)
Which is a good Bluetooth headset of about 300? 2022 high cost performance Bluetooth headset inventory
[graduation season] graduate seniors share how to make undergraduate more meaningful
leetcode2312. 卖木头块(困难,周赛)
MySQL主从延迟问题怎么解决
This is the report that leaders like! Learn dynamic visual charts, promotion and salary increase are indispensable
Four basic strategies for migrating cloud computing workloads
随机推荐
Parted command
The middle element and the rightmost element of the shutter
Experimental reproduction of variable image compression with a scale hyperprior
Ubuntu20.04 PostgreSQL 14 installation configuration record
Implementation principle of city selector component
Makefile simple induction
剑指 Offer 29. 顺时针打印矩阵
Architecture evolution from MVC to DDD
Software No.1
np. Where and torch Where usage
1069. Division of convex polygons (thinking, interval DP)
Construction and maintenance of business websites [11]
5g/4g pole gateway_ Smart pole gateway
From January 11, 2007 to January 11, 2022, I have been in SAP Chengdu Research Institute for 15 years
Sword finger offer 42 Maximum sum of continuous subarrays
Pytest testing framework
RTL8189FS如何关闭Debug信息
MySQL constraints and multi table query example analysis
What are the necessary things for students to start school? Ranking list of Bluetooth headsets with good sound quality
Electronic Society C language level 1 32, calculate the power of 2