Python: send mail using Resend

Official website: https://resend.com/

It's very simple, just call the api interface to send emails

Need to prepare parameters in advance

  • api_key The key applied from Resend
  • to_email Email address to receive emails
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)

Guess you like

Origin blog.csdn.net/mouday/article/details/132603530