Python:使用Resend发送邮件

官网:https://resend.com/

很简单,只需调用api接口,即可发送邮件

需要提前准备好参数

  • api_key 从Resend申请的key
  • to_email 接收邮件的邮箱地址
import requests

headers = {
    
    
    'Authorization': 'Bearer <api_key>',
    'Content-Type': 'application/json',
}

json_data = {
    
    
    'from': '[email protected]',
    'to': '<to_email>',
    'subject': 'Hello World',
    'html': '<p>Congrats on sending your <strong>first email</strong>!</p>',
}

response = requests.post('https://api.resend.com/emails', headers=headers, json=json_data)

猜你喜欢

转载自blog.csdn.net/mouday/article/details/132603530