#!/bin/bash # # Changed a few things up from my original version I am using # but thought others might want to have an easy way to send # emails to users using mailgun via bash.. # # be sure to replace the FROM field, subject, content, etc # just read the script and follow-along and modify accordingly. # # the contents of the file I am reading are email username: # someone@something.tld an-user # another@there.tld another # where@there.tld user3 filename="$1" apikey="api:key-1234abcd5678efghijklmnop" #your mailgun api key domain="shat.io" while read -a line do email=${line[0]} username=${line[1]} curl -s --user "${apikey}" \ https://api.mailgun.net/v3/${domain}/messages \ -F from='shat ' \ -F to="${username} <${email}>" \ -F subject='Put a real subject here homie..' \ -F text='Hello there, Shat here, showing you how to send some emails using mailgun. Feel free to use this example! Kind regards, Shat' > /dev/null echo "queued email to user: ${username} at ${email}" sleep 0.5 # I throttle, just because. done < "$filename"