{"id":23536308,"url":"https://github.com/raku-community-modules/email-sendgrid","last_synced_at":"2026-02-21T19:05:31.183Z","repository":{"id":66986687,"uuid":"238258687","full_name":"raku-community-modules/Email-SendGrid","owner":"raku-community-modules","description":"A Raku module for basic use of the SendGrid API for sending email.","archived":false,"fork":false,"pushed_at":"2024-12-25T11:02:41.000Z","size":16,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-21T10:53:48.447Z","etag":null,"topics":["email","raku","sendgrid-api"],"latest_commit_sha":null,"homepage":"https://raku.land/zef:raku-community-modules/Email::SendGrid","language":"Raku","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"artistic-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/raku-community-modules.png","metadata":{"files":{"readme":"README.md","changelog":"Changes","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2020-02-04T17:01:50.000Z","updated_at":"2024-12-25T11:21:40.000Z","dependencies_parsed_at":"2025-04-21T10:44:05.684Z","dependency_job_id":null,"html_url":"https://github.com/raku-community-modules/Email-SendGrid","commit_stats":null,"previous_names":["raku-community-modules/email-sendgrid"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raku-community-modules%2FEmail-SendGrid","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raku-community-modules%2FEmail-SendGrid/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raku-community-modules%2FEmail-SendGrid/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raku-community-modules%2FEmail-SendGrid/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/raku-community-modules","download_url":"https://codeload.github.com/raku-community-modules/Email-SendGrid/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250403832,"owners_count":21424794,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["email","raku","sendgrid-api"],"created_at":"2024-12-26T02:18:46.120Z","updated_at":"2025-10-17T20:17:59.867Z","avatar_url":"https://github.com/raku-community-modules.png","language":"Raku","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Actions Status](https://github.com/raku-community-modules/Email-SendGrid/actions/workflows/linux.yml/badge.svg)](https://github.com/raku-community-modules/Email-SendGrid/actions) [![Actions Status](https://github.com/raku-community-modules/Email-SendGrid/actions/workflows/macos.yml/badge.svg)](https://github.com/raku-community-modules/Email-SendGrid/actions) [![Actions Status](https://github.com/raku-community-modules/Email-SendGrid/actions/workflows/windows.yml/badge.svg)](https://github.com/raku-community-modules/Email-SendGrid/actions)\n\nNAME\n====\n\nEmail::SendGrid - Basic email sending via the SendGrid API\n\nDESCRIPTION\n===========\n\nA basic Raku module for sending email using the [SendGrid Web API (v3)](https://www.twilio.com/docs/sendgrid/for-developers/sending-email/api-getting-started).\n\nAt the time of writing, SendGrid allows sending up to 100 emails a day free of charge. This module most certainly does not provide full coverage of the SendGrid API; if you need more, pull requests are welcome.\n\nUsage\n=====\n\nConstruct an `Eamil::SendGrid` object using your SendGrid API key:\n\n```raku\nmy $sendgrid = Email::SendGrid.new(api-key =\u003e 'your_key_here');\n```\n\nThen call `send-mail` to send email:\n\n```raku\n$sendgrid.send-mail:\n  from =\u003e address('some@address.com', 'Sender name'),\n  to =\u003e address('target@address.com', 'Recipient name'),\n  subject =\u003e 'Yay, SendGrid works!',\n  content =\u003e {\n    'text/plain' =\u003e 'This is the plain text message',\n    'text/html' =\u003e '\u003cstrong\u003eHTML mail!\u003c/strong\u003e'\n  };\n```\n\nIt is not required to including a HTML version of the body. Optionally, pass `cc`, `bcc`, and `reply-to` to send these addresses. It is also possible to pass a list of up to 1000 addresses to `to`, `cc`, and `bcc`. \n\nIf sending the mail fails, an exception will be thrown. Since `Cro::HTTP::Client` is used internally, it will be an exception from that.\n\n```raku\nCATCH {\n    default {\n        note await .response.body;\n    }\n}\n```\n\nPass `:async` to `send-mail` to get a `Promise` back instead. Otherwise, it will be \u003cawait\u003eed for you by `send-mail`.\n\nClass / Methods reference\n=========================\n\nclass Email::SendGrid\n---------------------\n\nA partial implementation of the SendGrid v3 API, sufficient for using it to do basic email sending. Construct it with your API key (passed as the api-key parameter), and optionally a from address to be used for all of the emails sent. Construct with :persistent to use a persistent Cro HTTP client (can give better throughput if sending many emails).\n\n\n\nMinimal validation of an email address - simply that it has an @ sign.\n\nclass Email::SendGrid::Address\n------------------------------\n\nPairs together a name and email address, which are often needed together in the SendGrid API. A name is optional.\n\n\n\nRecipient lists may be an address or a list of addresses 1 to 1000 addresses.\n\n### multi sub address\n\n```raku\nmulti sub address(\n    $email\n) returns Mu\n```\n\nConstruct an Email::SendGrid::Address object from just an email address.\n\n### multi sub address\n\n```raku\nmulti sub address(\n    $email,\n    $name\n) returns Mu\n```\n\nConstruct an Email::SendGrid::Address object from an email address and a name.\n\n### has Str $.api-key\n\nThe SendGrid API key.\n\n### has Email::SendGrid::Address $.from\n\nThe default from address to use.\n\n### has Cro::HTTP::Client $.client\n\nThe Cro HTTP client used for communication.\n\n### method send-mail\n\n```raku\nmethod send-mail(\n    :$to! where { ... },\n    :$cc where { ... },\n    :$bcc where { ... },\n    Email::SendGrid::Address :$from = Code.new,\n    Email::SendGrid::Address :$reply-to,\n    Str :$subject!,\n    :%content!,\n    :$async,\n    :$sandbox\n) returns Mu\n```\n\nSend an email. The C\u003cto\u003e, C\u003ccc\u003e, and C\u003cbcc\u003e options may be a single Address object or a list of 1 to 1000 C\u003cAddress\u003e objects. Only C\u003cto\u003e is required; C\u003cfrom\u003e is required if there is no object-level from address. Optionally, a C\u003creply-to\u003e C\u003cAddress\u003e may be provided. A C\u003csubject\u003e is required, as is a C\u003c%content\u003e hash that maps mime types into the matching bodies. If `async` is passed, the call to the API will take place asynchronously, and a C\u003cPromise\u003e returned.\n\nAUTHOR\n======\n\nJonathan Worthington\n\nCOPYRIGHT AND LICENSE\n=====================\n\nCopyright 2020 Jonathan Worthington\n\nCopyright 2024 Raku Community\n\nThis library is free software; you can redistribute it and/or modify it under the Artistic License 2.0.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fraku-community-modules%2Femail-sendgrid","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fraku-community-modules%2Femail-sendgrid","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fraku-community-modules%2Femail-sendgrid/lists"}