mirror of
https://github.com/dreamhunter2333/cloudflare_temp_email.git
synced 2026-05-22 00:29:53 +08:00
docs: add x-custom-auth private site password hint to all API docs Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2.0 KiB
2.0 KiB
Send Email API
Send Email via HTTP API
This is a python example using the requests library to send emails.
send_body = {
"from_name": "Sender Name",
"to_name": "Recipient Name",
"to_mail": "Recipient Address",
"subject": "Email Subject",
"is_html": False, # Set whether it's HTML based on content
"content": "<Email content: html or text>",
}
res = requests.post(
"http://localhost:8787/api/send_mail",
json=send_body, headers={
"Authorization": f"Bearer {your_JWT_password}",
# "x-custom-auth": "<your_website_password>", # If private site password is enabled
"Content-Type": "application/json"
}
)
# Using body authentication
send_body = {
"token": "<your_JWT_password>",
"from_name": "Sender Name",
"to_name": "Recipient Name",
"to_mail": "Recipient Address",
"subject": "Email Subject",
"is_html": False, # Set whether it's HTML based on content
"content": "<Email content: html or text>",
}
res = requests.post(
"http://localhost:8787/external/api/send_mail",
json=send_body, headers={
# "x-custom-auth": "<your_website_password>", # If private site password is enabled
"Content-Type": "application/json"
}
)
Send Email via SMTP
Please first refer to Configure SMTP Proxy.
This is a python example using the smtplib library to send emails.
JWT Token Password: This is the email login password, which can be viewed in the password menu in the UI interface.
import smtplib
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
with smtplib.SMTP('localhost', 8025) as smtp:
smtp.login("jwt", "Enter your JWT token password here")
message = MIMEMultipart()
message['From'] = "Me <me@awsl.uk>"
message['To'] = "Admin <admin@awsl.uk>"
message['Subject'] = "Test Subject"
message.attach(MIMEText("Test Content", 'html'))
smtp.sendmail("me@awsl.uk", "admin@awsl.uk", message.as_string())