In My Previous Post, I share the method to send emails via PHP cURL & PHP Guzzle using Pepipost JSON API in this tutorial we are going to see the method to Send Emails from Shell Script using Pepipost API v2.

Here is the Simple Bash Shell Script Which helps us to Send Emails via Pepipost.

  • Create JSON File named as params.json
{"personalizations": [{
    "recipient": "user@example.com",
    "attributes": {
        "NAME": "Hello User"
    }
}],
"tags": "Post Updates",
"from": {
    "fromEmail": "me@example.com",
    "fromName": "Santhosh veer"
},
"subject": "[Blog Post Updates]",
"content": "Hi,[%NAME%] This is My First test Email",
"replyToId": "me@example.com"
}
  • Create bash File Named as pepi.sh
#!/bin/bash
 
PEPIPOST_API_KEY="YOUR API KEY"

curl --request POST \
--url https://api.pepipost.com/v2/sendEmail \
    --header "api_key: $PEPIPOST_API_KEY" \
    --header "content-type: application/json" \
    --data @params.json
  • Execute the Script
bash pepi.sh
  • Output Response
{"data":{},"message":"Success"}