当前位置:网站首页>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 ")
边栏推荐
- 城市选择器组件实现原理
- Selection of field types for creating tables in MySQL database
- 剑指 Offer II 031. 最近最少使用缓存
- "C language programming", 4th Edition, edited by he Qinming and Yan Hui, after class exercise answers Chapter 3 branch structure
- How to solve MySQL master-slave delay problem
- CSDN insertion directory in 1 second
- 自动浏览拼多多商品
- RTL8189FS如何关闭Debug信息
- MySQL constraints and multi table query example analysis
- [question] - why is optical flow not good for static scenes
猜你喜欢

剑指 Offer 62. 圆圈中最后剩下的数字

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

WebGPU(一):基本概念
![[Video] Markov chain Monte Carlo method MCMC principle and R language implementation | data sharing](/img/ba/dcb276768b1a9cc84099f093677d29.png)
[Video] Markov chain Monte Carlo method MCMC principle and R language implementation | data sharing

How to execute an SQL in MySQL

软件开发生命周期 --瀑布模型

1069. Division of convex polygons (thinking, interval DP)

How to use redis ordered collection

如何远程、在线调试app?

Matlab uses resample to complete resampling
随机推荐
leetcode2309. 兼具大小写的最好英文字母(简单,周赛)
医药管理系统(大一下C语言课设)
mysql列转行函数指的是什么
PR second training
Redis有序集合如何使用
MySQL主从延迟问题怎么解决
CSDN insertion directory in 1 second
leetcode2311. Longest binary subsequence less than or equal to K (medium, weekly)
Matlab uses audiorecorder and recordblocking to record sound, play to play sound, and audiobook to save sound
Sword finger offer 31 Stack push in and pop-up sequence
分卷压缩,解压
JPM 2021 most popular paper released (with download)
Construction and maintenance of business websites [12]
城市选择器组件实现原理
[graduation season] graduate seniors share how to make undergraduate more meaningful
Regular expression learning notes
Openssl3.0 learning XXI provider encoder
[技术发展-21]:网络与通信技术的应用与发展快速概览-1- 互联网网络技术
From January 11, 2007 to January 11, 2022, I have been in SAP Chengdu Research Institute for 15 years
The middle element and the rightmost element of the shutter