https://github.com/mrchypark/sendgridr
Mail Sender Using SendGrid mail API
https://github.com/mrchypark/sendgridr
hacktoberfest hacktoberfest2021 mail mailer package r sendgrid
Last synced: 3 months ago
JSON representation
Mail Sender Using SendGrid mail API
- Host: GitHub
- URL: https://github.com/mrchypark/sendgridr
- Owner: mrchypark
- License: other
- Created: 2018-09-19T07:48:20.000Z (about 7 years ago)
- Default Branch: main
- Last Pushed: 2025-06-02T14:35:22.000Z (5 months ago)
- Last Synced: 2025-08-08T05:28:41.650Z (3 months ago)
- Topics: hacktoberfest, hacktoberfest2021, mail, mailer, package, r, sendgrid
- Language: R
- Homepage: https://mrchypark.github.io/sendgridr/
- Size: 5.42 MB
- Stars: 24
- Watchers: 2
- Forks: 7
- Open Issues: 6
-
Metadata Files:
- Readme: README.Rmd
- Changelog: NEWS.md
- Contributing: .github/CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Code of conduct: .github/CODE_OF_CONDUCT.md
- Support: .github/SUPPORT.md
Awesome Lists containing this project
- awesome-shiny-extensions - sendgridr - Send emails with SendGrid mail API (v3). (Backend / Notification Integration)
- jimsghstars - mrchypark/sendgridr - Mail Sender Using SendGrid mail API (R)
README
---
output: github_document
---
```{r setup, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
library(sendgridr)
```
# sendgridr 
[](https://lifecycle.r-lib.org/articles/stages.html#experimental)
[](https://github.com/mrchypark/sendgridr/actions)
[](https://github.com/mrchypark/sendgridr/actions/workflows/send-test.yaml)
[](https://CRAN.R-project.org/package=sendgridr)
[](https://mrchypark.r-universe.dev/)
[](https://mrchypark.r-universe.dev/packages)
[](https://cran.r-project.org/package=sendgridr)
[](https://CRAN.R-project.org/package=sendgridr)
The goal of sendgridr is to mail using r with sendgrid service that provides free 100 mail per day forever.
## Installation
```
# CRAN version
install.packages("sendgridr")
# Dev version
install.packages("sendgridr", repos = "https://mrchypark.r-universe.dev")
```
## Set API key for authentication
You can set api key using `auth_set()` function.
Also `auth_check()` function check api key works.
```
auth_check()
auth_set()
```
### Using with Shiny Apps
For non-interactive environments like Shiny, you can provide the SendGrid API key via the `SENDGRID_API_KEY` environment variable. For example:
```
Sys.setenv(SENDGRID_API_KEY = "YOUR_API_KEY")
library(sendgridr)
```
## Send mail
### Example code
Please replace your conditions.
```
mail() |>
from("example1@mail.com", "example name for display") |>
to("example2@mail.com", "example name for display 2") |>
subject("test mail title") |>
body("hello world!") |>
## attachments is optional
attachments("report.html") |>
send()
```
### sg_mail class
`mail()` function create sg_mail class object and also list.
sg_mail class only has print method.
```{r}
sendproject1 <- mail()
class(sendproject1)
sendproject1
```
to, from, subject, body are required. cc, bcc, attachments are optional.
### multi- setting using inline
to, cc, bcc, attachments functions are able to set multi values.
```{r}
library(sendgridr)
mail() |>
from("example1@mail.com", "toexam@mail.com") |>
to("toexam1@mail.com", "1 exam") |>
to("toexam2@mail.com", "2 exam") |>
to("toexam3@mail.com", "3 exam") |>
subject("test mail title") |>
body("hello world!")
```
## Code of Conduct
Please note that the sendgridr project is released with a [Contributor Code of Conduct](https://mrchypark.github.io/sendgridr/CODE_OF_CONDUCT.html). By contributing to this project, you agree to abide by its terms.