Skip to content

Instantly share code, notes, and snippets.

@sh4t
Last active May 12, 2017 18:53
Show Gist options
  • Save sh4t/24caf59d5cadab7cdff9 to your computer and use it in GitHub Desktop.
Save sh4t/24caf59d5cadab7cdff9 to your computer and use it in GitHub Desktop.

Revisions

  1. sh4t revised this gist Nov 7, 2015. 1 changed file with 4 additions and 1 deletion.
    5 changes: 4 additions & 1 deletion send_emails.sh
    Original file line number Diff line number Diff line change
    @@ -7,7 +7,10 @@
    # 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:
    # [email protected] an-user
    # [email protected] another
    # [email protected] user3

    filename="$1"
    apikey="api:key-1234abcd5678efghijklmnop" #your mailgun api key
  2. sh4t created this gist Nov 7, 2015.
    36 changes: 36 additions & 0 deletions send_emails.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,36 @@
    #!/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.
    #


    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 <[email protected]>' \
    -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"