sendgrid

Version, currently master branch1 version
  • master branchlatestMay 7, 2020

github.com/dlanileonardo/sendgrid.cr

Simple lib to send mail using Sendgrid in Crystal-Lang

16 stars
0 dependents
License: MIT

Installation

# Add this to your shard.yml
dependencies:
  sendgrid:
    github: dlanileonardo/sendgrid.cr
    branch: master

master is a branch, not a release, so this tracks it rather than pinning a version.

Then run:

shards install

shard.yml

Crystal
0.34.0
License
MIT
Author
Dlani <dlanileonardo@gmail.com>

Dependencies

This version declares no dependencies.

README

# sendgrid.cr

Simple lib to send mail using Sendgrid in Crystal-Lang

![CI](https://github.com/dlanileonardo/sendgrid.cr/workflows/CI/badge.svg)

## Installation

Add this to your application's `shard.yml`:

```yaml
dependencies:
  sendgrid:
    github: dlanileonardo/sendgrid.cr
```

## Usage

```crystal
require "sendgrid"
```

### Using Helpers

```
client = Sendgrid::Client.new("https://api.sendgrid.com/v3/mail/send", API_KEY)
message = Sendgrid::Message.new
message.from = Sendgrid::Address.new(email="darthvader@host.com", name="Darth Vader")
message.to << Sendgrid::Address.new(email="lukeskywalker@starwars.stars", name="Luke Skywalker")
message.subject = "Good News"
message.content = Sendgrid::Content.new("No, I am your father.")
send = client.send message
puts send.status_code
puts send.body
```

### Print JSON

```
message = Sendgrid::Message.new
message.from = Sendgrid::Address.new(email="darthvader@host.com", name="Darth Vader")
message.reply_to = Sendgrid::Address.new(email="anakinskywalker@starwars.stars", name="Anakin Skywalker")
message.to << Sendgrid::Address.new(email="lukeskywalker@starwars.stars", name="Luke Skywalker")
message.subject = "Good News"
message.content = Sendgrid::Content.new("No, I am your father.")
extra_fields = {
  "template_id" => "death_star",
  "asm" => {
    "group_id" => "skywalkers",
    "groups_to_display" => "skywalkers"
  } of String => Sendgrid::ExtraFieldsType,
  "attachments" => [
    {
      "content" => "Blue LightSaber",
      "filename" => "blulightsaber.png"
    } of String => Sendgrid::ExtraFieldsType
  ] of Sendgrid::ExtraFieldsType
} of String => Sendgrid::ExtraFieldsType
message.extra_fields.merge!(extra_fields)
puts message.to_json
```

## Contributing

1. Fork it ( https://github.com/dlanileonardo/sendgrid.cr/fork )
2. Create your feature branch (git checkout -b my-new-feature)
3. Commit your changes (git commit -am 'Add some feature')
4. Push to the branch (git push origin my-new-feature)
5. Create a new Pull Request

## Contributors

- [dlanileonardo](https://github.com/dlanileonardo)  - creator, maintainer