{"id":24901674,"url":"https://github.com/crisward/mailer","last_synced_at":"2025-10-22T03:08:39.631Z","repository":{"id":56455551,"uuid":"104925120","full_name":"crisward/mailer","owner":"crisward","description":"Simple Email Sending Client for Mailgun \u0026 Sendgrid services in crystal","archived":false,"fork":false,"pushed_at":"2020-11-06T10:24:10.000Z","size":53,"stargazers_count":15,"open_issues_count":2,"forks_count":3,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-04-17T04:01:51.283Z","etag":null,"topics":["crystal","email","mailgun","sendgrid"],"latest_commit_sha":null,"homepage":"","language":"Crystal","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/crisward.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-09-26T18:50:52.000Z","updated_at":"2024-03-09T22:13:51.000Z","dependencies_parsed_at":"2022-08-15T19:10:10.952Z","dependency_job_id":null,"html_url":"https://github.com/crisward/mailer","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crisward%2Fmailer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crisward%2Fmailer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crisward%2Fmailer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crisward%2Fmailer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/crisward","download_url":"https://codeload.github.com/crisward/mailer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":236719443,"owners_count":19194048,"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":["crystal","email","mailgun","sendgrid"],"created_at":"2025-02-01T21:17:05.426Z","updated_at":"2025-10-16T13:30:28.198Z","avatar_url":"https://github.com/crisward.png","language":"Crystal","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Mailer\n\nThis project aims to provide a common api for popular email providers. It currently supports\n* Mailgun\n* Sendgrid\n\nI also plan to add a wrapper for [SMTP](https://github.com/arcage/crystal-email)\n\n## Installation\n\nAdd this to your application's `shard.yml`:\n\n```yaml\ndependencies:\n  mailer:\n    github: crisward/mailer\n```\n\n## Usage\n\n```crystal\nrequire \"mailer\"\n\nMailer.config(provider: Mailer::Mailgun.new(key: ENV[\"MAILGUN_KEY\"], domain: ENV[\"MAILGUN_DOMAIN\"]))\nemail = Mailer::Message.new\nemail.to(\"them@somedomain.com\",\"their_name\")\nemail.from = \"you@yourdomain.com\"\nemail.subject = \"Hello\"\nemail.text = \"Some plain text messaeg\"\nemail.html = \"\u003cp\u003eSome html message \u003cimg src='cid:logo.jpg'\u003e\u003c/p\u003e\"\nemail.attachment = Mailer::Attachment.new(filename: \"test.pdf\" , path: \"./spec/test.pdf\")\nemail.inline = Mailer::Attachment.new(filename: \"logo.jpg\" , path: \"./spec/test.png\")\nemail.send\n```\n\nTo use sendgrid, swap the first line to\n\n```\nMailer.config(provider: Mailer::Sendgrid.new(key: \"your sendgrid api key\"))\n```\n\n## Testing Your App\n\nWhile testing your app, you probably won't want to send real emails.\nYou can use the built in Mock provider for this.\n\n```crystal\n# eg for kemal\nif ENV[\"KEMAL_ENV\"]? != \"test\"\n  Mailer.config(provider: Mailer::Mailgun.new(key: ENV[\"MAILGUN_KEY\"], domain: ENV[\"MAILGUN_DOMAIN\"]))\nelse\n  Mailer.config(provider:Mailer::Mock.new())\nend\n```\n\n## Development\n\nRunning tests\n\n```bash\n# mock\ncrystal spec\n\n#mailgun\nMAILGUN_KEY=\"your-api-key\" MAILGUN_DOMAIN=\"mailgun-domain\" EMAIL=\"your@email.com\" crystal spec\n\n#sendgrid\nSENDGRID_KEY=\"your-api-key\" EMAIL=\"your@email.com\" crystal spec\n\n```\n\n\n## Todo\n\nThis library isn't full baked. It works, but there are some thing which need adding\n- [ ] Error Handling\n- [ ] Logging\n- [ ] Adding SMTP option\n\n## Contributing\n\n1. Fork it ( https://github.com/crisward/mailer/fork )\n2. Create your feature branch (git checkout -b my-new-feature)\n3. Commit your changes (git commit -am 'Add some feature')\n4. Push to the branch (git push origin my-new-feature)\n5. Create a new Pull Request\n\n## Contributors\n\n- [Cris Ward](https://github.com/crisward) - creator, maintainer\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcrisward%2Fmailer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcrisward%2Fmailer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcrisward%2Fmailer/lists"}