Postman本身并不支持直接發送郵件功能,但你可以使用Postman來發送HTTP請求,然后通過這些請求來觸發郵件發送的腳本或程序。以下是如何在Debian系統上使用Postman發送HTTP請求以測試郵件發送的步驟:
https://api.example.com/send-email
。Content-Type
為application/json
。{
"to": "recipient@example.com",
"subject": "Test Email",
"body": "This is a test email sent using Postman."
}
requests
庫來發送郵件:import requests
def send_email(to, subject, body):
url = "https://api.example.com/send-email"
headers = {
"Content-Type": "application/json"
}
payload = {
"to": to,
"subject": subject,
"body": body
}
response = requests.post(url, json=payload, headers=headers)
return response.json()
# 示例調用
response = send_email("recipient@example.com", "Test Email", "This is a test email sent using Postman.")
print(response)
https://api.example.com/send-email
,并在請求體中輸入以下內容:{
"to": "recipient@example.com",
"subject": "Test Email",
"body": "This is a test email sent using Postman."
}
請注意,上述步驟中的https://api.example.com/send-email
是一個示例URL,你需要替換為實際提供郵件發送功能的API端點。同樣,recipient@example.com
應替換為實際的收件人郵箱地址。