{"id":30794031,"url":"https://github.com/sendgrid/sendgrid-apex","last_synced_at":"2026-02-14T14:31:22.466Z","repository":{"id":66169734,"uuid":"20578530","full_name":"sendgrid/sendgrid-apex","owner":"sendgrid","description":"SendGrid (http://sendgrid.com) Apex helper library.","archived":false,"fork":false,"pushed_at":"2016-02-20T00:18:34.000Z","size":29,"stargazers_count":35,"open_issues_count":9,"forks_count":21,"subscribers_count":205,"default_branch":"master","last_synced_at":"2025-09-05T16:46:26.114Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Apex","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sendgrid.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-06-06T21:18:32.000Z","updated_at":"2024-08-16T19:17:00.000Z","dependencies_parsed_at":"2023-05-05T10:28:21.750Z","dependency_job_id":null,"html_url":"https://github.com/sendgrid/sendgrid-apex","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/sendgrid/sendgrid-apex","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sendgrid%2Fsendgrid-apex","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sendgrid%2Fsendgrid-apex/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sendgrid%2Fsendgrid-apex/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sendgrid%2Fsendgrid-apex/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sendgrid","download_url":"https://codeload.github.com/sendgrid/sendgrid-apex/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sendgrid%2Fsendgrid-apex/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29447195,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-14T14:10:32.461Z","status":"ssl_error","status_checked_at":"2026-02-14T14:09:49.945Z","response_time":53,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":[],"created_at":"2025-09-05T16:26:54.211Z","updated_at":"2026-02-14T14:31:22.461Z","avatar_url":"https://github.com/sendgrid.png","language":"Apex","funding_links":[],"categories":[],"sub_categories":[],"readme":"# sendgrid-apex\n\nThis Apex Toolkit allows you to quickly and easily send emails through [SendGrid](http://sendgrid.com) using [Salesforce Apex](https://developer.salesforce.com/page/Apex).\n\n```java\nSendGrid sendgrid = new SendGrid('username', 'password');\n\nSendGrid.email email = new SendGrid.Email();\nemail.addTo('foo@bar.com');\nemail.setFrom('me@bar.com');\nemail.setSubject('Subject goes here');\nemail.setText('Hello World!');\n\nString response = sendgrid.send(email);\n```\n\n## Installation\n\nTo start using the SendGrid Apex Toolkit in your Salesforce Org, install the unmanaged package of the library with the following URL:\n\n1.0: \u003chttps://login.salesforce.com/packaging/installPackage.apexp?p0=04tF0000000SwjP\u003e\n\nClick Continue -\u003e Next -\u003e Next -\u003e Install.\n\n## Usage\n\nTo begin using this library, initialize the SendGrid object with your SendGrid credentials.\n\n\n```java\nSendGrid sendgrid = new SendGrid('username', 'password');\n```\n\nAdd your message details.\n\n```java\nSendGrid.email email = new SendGrid.Email();\nemail.addTo('foo@bar.com');\nemail.setFrom('me@bar.com');\nemail.setSubject('Subject goes here');\nemail.setText('Hello World!');\nemail.setHtml('\u003cstrong\u003eHello World!\u003c/strong\u003e');\n```\n\nSend it.\n\n```java\nString response = sendgrid.send(email);\n```\n\n### addTo\n\n```java\nSendGrid.email email = new SendGrid.Email();\nemail.addTo('email@example.com');\nemail.addTo('email2@example.com');\n```\n\n### setTos\n\n```java\nSendGrid.email email = new SendGrid.Email();\nList\u003cString\u003e tos = new List\u003cString\u003e { 'setTos@mailinator.com' };\nemail.setTos(tos);\n```\n\n### setFrom\n\n```java\nSendGrid.email email = new SendGrid.Email();\nemail.setFrom('foo@bar.com');\n```\n\n### setFromName\n\n```java\nSendGrid.email email = new SendGrid.Email();\nemail.setFromName('Example Lady');\n```\n\n### setReplyTo\n\n```java\nSendGrid.email email = new SendGrid.Email();\nemail.setReplyTo('foo@bar.com');\n```\n\n### Bcc\n\nUse multiple `addTo`s as a superior alternative to `setBcc`.\n\n```java\nSendGrid.email email = new SendGrid.Email();\nemail.addTo('foo@bar.com');\nemail.addTo('someotheraddress@bar.com');\nemail.addTo('another@another.com');\n...\n```\n\nBut if you do still have a need for Bcc you can do the following.\n\n```java\nSendGrid.email email = new SendGrid.Email();\nemail.addBcc('foo@bar.com');\n```\n\n### setSubject\n\n```java\nSendGrid.email email = new SendGrid.Email();\nemail.setSubject('This is a subject');\n```\n\n### setText\n\n```java\nSendGrid.email email = new SendGrid.Email();\nemail.setText('This is some text');\n```\n\n### setHtml\n\n```java\nSendGrid.email email = new SendGrid.Email();\nemail.setHtml('\u003ch1\u003eThis is an html email\u003c/h1\u003e');\n```\n\n### addSubstitution\n\n```java\nSendGrid.email email = new SendGrid.Email();\nList\u003cString\u003e vals = new List\u003cString\u003e { 'val' };\nemail.addSubstitution('sub', vals);\n```\n\n### addUniqueArg\n\n```java\nSendGrid.email email = new SendGrid.Email();\nemail.addUniqueArg('add_unique_argument_key', 'add_unique_argument_value');\n```\n\n### addCategory\n\n```java\nSendGrid.email email = new SendGrid.Email();\nemail.addCategory('Category 1');\nemail.addCategory('Category 2');\n```\n\n### addSection\n\n```java\nSendGrid.email email = new SendGrid.Email();\nemail.addSection('set_section_key', 'set_section_value');\n```\n\n### addFilter\n\n```java\nSendGrid.email email = new SendGrid.Email();\nemail.addFtiler('footer', 'text/html', '\u003cstrong\u003eboo\u003c/strong\u003e');\n```\n\n### addHeader\n\nYou can add standard email message headers as necessary.\n\n```java\nSendGrid.email email = new SendGrid.Email();\nemail.addTo('foo@bar.com');\n...\nemail.addHeader('X-Sent-Using', 'SendGrid-API');\nemail.addHeader('X-Transport', 'web');\n```\n\n### addAttachmentStream\n\n```java\nSendGrid.email email = new SendGrid.Email();\n\n// as a string\nemail.addAttachmentStream('text.txt', 'somerandomcontentyouwant');\n\n// as a blob\nString text = 'This is an attachment.';\nBlob as_blob = Blob.valueof(text);\nemail.addAttachmentStream('text.txt', as_blob);\n```\n\n## Development\n\nGetting your development environment setup takes some careful steps. So, we have explained the process here to save you some time:\n\n### Setup Salesforce.com\n\n[Create a salesforce.com developer account](https://developer.salesforce.com/signup).\n\nYou'll receive an email from Salesforce with a link to confirm. Click it.\n\nOn the next screen, set your password.\n\nYou now have a developer account.\n\nGenerate your security token. We will need this later. While logged into your developer account, click \"Your Name \u003e My Settings\" at the top right portion of your developer account dashboard.\n\nThen on the left side of the screen click \"Personal \u003e Reset My Security Token\". Click the \"Reset Security Token\" button. Salesforce emails you a security token. You will need this later.\n\n### Setup local environment\n\n[Install Sublime Text 3](http://www.sublimetext.com/3).\n\n[Install Mavens Mate](http://mavensmate.com/).\n\nOpen up Sublime Text 3, and then open up Mavens Mate on your machine. There should be a Mavens Mate icon, at the top bar of your screen. Click it and then click \"Plugins\".\n\nOn the next window, click \"Install Plugin\". This installs the Mavens Mate plugin into Sublime Text 3.\n\nClose and reopen Sublime Text 3.\n\nClick Mavens Mate \u003e Settings \u003e User at the top Sublime Text 3 Toolbar.\n\nThis will open a file called `mavensmate.sublime-settings`. Paste the following in that file. Adjust to the path and directory you want to store your salesforce code in. It must be an absolute path.\n\n```json\n{\n  \"mm_workspace\": \"/Users/your_username/code/salesforce\"\n}\n```\n\nSave and close that file.\n\n### Clone the repo\n\n```\ncd /Users/your_username/code/salesforce\ngit clone https://github.com/sendgrid/sendgrid-apex.git\n```\n### Open the project\n\nWith Sublime Text 3 still open, click \"File \u003e Open\", and open the sendgrid-apex folder.\n\n### Create the project on Salesforce\n\nRight click on the sendgrid-apex containing folder, and choose \"MavensMate \u003e Create MavensMate Project\".\n\nOn the next screen enter the following:\n\n* For project name: 'sendgrid-apex' \n* For username: enter your email address\n* For password: enter your password APPENDED with your salesforce security token. (see above for how to generate the security token) \n\nWhen you're ready click the 'Create Project' button.\n\nThis will create the project up on Salesforce.com and locally on your machine. That's what we want.\n\nNext, the final and most important step.\n\nClick \"Mavens Mate \u003e Project \u003e Compile Project\".\n\n### You're done\n\nYou're done!\n\nNow go ahead and develop. I recommend [this tutorial](https://github.com/scottmotte/apex-hello-world) or [this blog post](http://sendgrid.com/blog/hello-world-apex/) for learning some basics of developing with Apex.\n\n### Additional: Creating the unmanaged package.\n\nSearch for \"packages\".\n\nClick \"Create \u003e Packages\".\n\nClick \"New\" under Packages.\n\nName the package \"sendgrid-apex\" and click save.\n\nOn the list of packages screen, now click \"sendgrid-apex\".\n\nOn the next screen under components, click \"Add\".\n\nOn the next screeen choose \"Apex Class\" under Component Type.\n\nCheck all the SendGrid related classes. \n\nThen click \"Add to Package\".\n\nThen click \"Add\" again.\n\nThis time on the next screen choose \"Remote Site\".\n\nCheck the SendGrid Remote Site, and click \"Add to Package\".\n\nThen on the package show page, click \"Upload\".\n\nOn the next screen, enter \"052114-sendgrid-apex\" for the name (change the mm/dd/yy to the current).\n\nSet version number to 1.0. \n\nSet the description to: \"This Apex Toolkit allows you to quickly and easily send emails through SendGrid using Salesforce Apex.\"\n\nScroll down to the very bottom and click \"Upload\".\n\nCopy and paste the installation url and place in the README.\n## Contributing\n\n1. Fork it\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Added some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create new Pull Request\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsendgrid%2Fsendgrid-apex","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsendgrid%2Fsendgrid-apex","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsendgrid%2Fsendgrid-apex/lists"}