IMmailgun

The goal of IMmailgun is to make sending emails from R easy. To use it, you will need a mailgun account.

Example

This is a basic example which shows you how to solve a common problem:

library(IMmailgun)
email_client <- mailgun$new(url = url, api_key = api_key, from = from)

email_client$sendEmail(to = c("[email protected]", "[email protected]"), 
                       subject = "Test", plaintext = "Hola a todos!")
#> [[1]]
#> Response [https://api.mailgun.net/v3/email.ignacio.website/messages]
#>   Date: 2017-11-18 13:59
#>   Status: 200
#>   Content-Type: application/json
#>   Size: 109 B
#> {
#>   "id": "<[email protected]>",
#>   "message": "Queued. Thank you."
#> 
#> [[2]]
#> Response [https://api.mailgun.net/v3/email.ignacio.website/messages]
#>   Date: 2017-11-18 13:59
#>   Status: 200
#>   Content-Type: application/json
#>   Size: 110 B
#> {
#>   "id": "<[email protected]>",
#>   "message": "Queued. Thank you."

Add attachemt


email_client$sendEmail(to = "[email protected]", 
                       subject = "Test with attachment", 
                       plaintext = "Check the attachment",
                       attachment = './README.md')
#> [[1]]
#> Response [https://api.mailgun.net/v3/email.ignacio.website/messages]
#>   Date: 2017-11-18 13:59
#>   Status: 200
#>   Content-Type: application/json
#>   Size: 109 B
#> {
#>   "id": "<[email protected]>",
#>   "message": "Queued. Thank you."

Get stats

email_client$stats()
#>                 id  event total_count created_at
#> 1 512b93ba0c7f0ab9 opened           1 2017-11-18
#> 2 5cc697702a96e913 opened           1 2017-11-16
#> 3 39f91001065c7cca opened           6 2017-11-15
#> 4 ede64ad2596dc9a5 opened           3 2017-11-14