Python 自动化发送邮件脚本

先上代码

# @Time    : 2022/10/17 11:42
# @Author  : fangkaitao
import smtplib
from email.message import EmailMessage
import pandas as pd

def send_email(remail, rsubject, rcontent):
    email = EmailMessage()                          # Creating a object for EmailMessage
    email['from'] = 'The Pythoneer Here'            # Person who is sending
    email['to'] = remail                            # Whom we are sending
    email['subject'] = rsubject                     # Subject of email
    email.set_content(rcontent)                     # content of email
    with smtplib.SMTP(host='smtp.gmail.com', port=587)as smtp:
        smtp.ehlo()                                 # server object
        smtp.starttls()                             # used to send data between server and client
        smtp.login("deltadelta371@gmail.com", "delta@371")  # login id and password of gmail
        smtp.send_message(email)                    # Sending email
        print("email send to ",remail)              # Printing success message

if __name__ == '__main__':
    df = pd.read_excel('list.xlsx')
    length = len(df)+1

    for index, item in df.iterrows():
        email = item[0]
        subject = item[1]
        content = item[2]

可用于一些网站服务的反馈
或者客户端注册时,发送验证码功能
还有一些信息推送
等等,各发其想,还可用于许许多多的功能

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值