当前位置:网站首页>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 ")
边栏推荐
- Open那啥的搭建文档
- flutter 中間一個元素,最右邊一個元素
- [C #] use regular verification content
- Number of palindromes in C language (leetcode)
- Medical management system (C language course for freshmen)
- Sword finger offer II 031 Least recently used cache
- Which is a good Bluetooth headset of about 300? 2022 high cost performance Bluetooth headset inventory
- Discussion on the idea of platform construction
- Spend a week painstakingly sorting out the interview questions and answers of high-frequency software testing / automated testing
- This is the form of the K-line diagram (pithy formula)
猜你喜欢
Opencascade7.6 compilation
花一个星期时间呕心沥血整理出高频软件测试/自动化测试面试题和答案
城市选择器组件实现原理
MySQL约束与多表查询实例分析
1069. Division of convex polygons (thinking, interval DP)
1222. Password dropping (interval DP, bracket matching)
From January 11, 2007 to January 11, 2022, I have been in SAP Chengdu Research Institute for 15 years
How does MySQL solve the problem of not releasing space after deleting a large amount of data
Redis环境搭建和使用的方法
734. Energy stone (greed, backpack)
随机推荐
Construction and maintenance of business websites [10]
Number of palindromes in C language (leetcode)
Design and implementation of key value storage engine based on LSM tree
"C language programming", 4th Edition, edited by he Qinming and Yan Hui, after class exercise answers Chapter 3 branch structure Exercise 3
自动浏览拼多多商品
Implementation principle of city selector component
CSDN article underlined, font color changed, picture centered, 1 second to understand
【视频】马尔可夫链蒙特卡罗方法MCMC原理与R语言实现|数据分享
RTL8189FS如何关闭Debug信息
Based on configured schedule, the given trigger will never fire
What style of Bluetooth headset is easy to use? High quality Bluetooth headset ranking
2022 Q2 - Summary of skills to improve skills
Matlab uses resample to complete resampling
pytest 测试框架
Parted command
【深度学习】infomap 人脸聚类 facecluster
leetcode2309. The best English letters with both upper and lower case (simple, weekly)
2022 Q2 - résumé des compétences pour améliorer les compétences
Automatically browse pinduoduo products
Construction and maintenance of business websites [14]