OS/linux

curl로 메일 서비스 api를 이용해 전송 테스트 하는 방법

bluebamus 2023. 10. 16.

 - 3개 업체를 사용하고 있기에 이에 대한 테스트를 진행한다.

 - 스팸을 막기 위해 보내는 사람의 메일은 등록된 도메인 주소야만 하는 경우가 대다수이다.

 

1. sendblue

curl --request POST \
  --url https://api.sendgrid.com/v3/mail/send \
  --header 'Authorization: Bearer {api 키}' \
  --header 'Content-Type: application/json' \
  --data '{"personalizations": [{"to": [{"email": "받는 사람 메일"}]}],"from": {"email": "sendeexampexample@example.com"},"subject": "Hello, World!","content": [{"type": "text/plain", "value": "Heya!"}]}'

 

2. sendinblue -> brevo 로 업체명이 변경됨

curl --request POST \
  --url https://api.brevo.com/v3/smtp/email \
  --header 'accept: application/json' \
  --header 'api-key: {api 키}' \
  --header 'content-type: application/json' \
  --data '{  
   "sender":{  
      "name":"Sender Alex",
      "email":"보내는 사람 메일"
   },
   "to":[  
      {  
         "email":"test@naver.com",
         "name":"test"
      }
   ],
   "subject":"Hello world",
   "htmlContent":"<html><head></head><body><p>Hello,</p>This is my first transactional email sent from Brevo.</p></body></html>"
}'

 

3. mailgun

curl -s --user 'api:YOUR_API_KEY' \
https://api.mailgun.net/v3/{등록된 도메인 주소}/messages \
-F from='Excited User {보내는 사람 메일 주}소' \
-F to={받는 사람 메일} \
-F subject='Hello' \
-F text='Testing some Mailgun awesomeness!'

댓글