Happy !
newapplesho / sendgrid-smalltalk
Project infos
| License | MIT |
| Tags | sendgrid, mail |
| Creation date | 2015-07-18 |
| Website | https://github.com/newapplesho/sendgrid-smalltalk |
Monticello registration
About sendgrid-smalltalk
SendGrid Smalltalk
SendGrid API Library to send emails very easily using Smalltalk. You can get started in minutes using Metacello and FileTree.
Features
- Web API's Mail
- Marketing Email API (supported Categories, Emails, Lists)
Requirement
Smalltalk
- Pharo 4.0
How to install
Gofer new
url:'http://smalltalkhub.com/mc/newapplesho/sendgrid-smalltalk/main';
package: 'ConfigurationOfSendGrid';
load.
(Smalltalk at: #ConfigurationOfSendGrid) load.
How to use
Web API's Email
You can read official documentation on the Web API's Mail feature here.
Email Body (text)
mail := (SGMail apiUser: 'your_sendgrid_username' apiKey:'your_sendgrid_password').
mail from: 'foo@example.com'.
mail fromName: 'Smalltalker'.
mail to: 'bar@example.com'.
mail subject:'SendGrid Test Mail'.
mail text:'My first email through SendGrid. Sent from Pharo Smalltalk.'.
client :=SendGridClient new.
client send: mail.
or
mail := (SGMail apiUser: 'your_sendgrid_username' apiKey:'your_sendgrid_password').
mail from: 'foo@example.com'.
mail fromName: 'Smalltalker'.
mail to: 'bar@example.com'.
mail subject:'SendGrid Test Mail'.
mail text:'My first email through SendGrid. Sent from Pharo Smalltalk.'.
mail send.
Email Body (html)
mail := (SGMail apiUser: 'your_sendgrid_username' apiKey:'your_sendgrid_password').
mail from: 'foo@example.com'.
mail fromName: 'Smalltalker'.
mail to: 'bar@example.com'.
mail subject:'SendGrid Test Mail'.
mail html:'<h1>My first email through SendGrid</h1><p>Sent from Pharo Smalltalk</p>'.
mail send.
Marketing Email API
Lists
add
sg := (SGMEAPILists apiUser: 'your_sendgrid_username' apiKey:'your_sendgrid_password').
sg add:'foobar'. "print it ==> a JsonObject('message'->'success' )"
edit
sg := (SGMEAPILists apiUser: 'your_sendgrid_username' apiKey:'your_sendgrid_password').
sg renameListFrom: 'foobar' to: 'foobar2'.
get
(SGMEAPILists apiUser: 'your_sendgrid_username' apiKey:'your_sendgrid_password') get.
delete
(SGMEAPILists apiUser: 'your_sendgrid_username' apiKey:'your_sendgrid_password')
delete:'foobar'.
Emails
add
json := JsonObject new.
json at:'name' put:'test'.
json at:'email' put:'foobar@example.com'.
(SGMEAPICategories apiUser: 'your_sendgrid_username' apiKey:'your_sendgrid_password')
list: 'foobar';
datum: (Array with: json asJsonString); add.
get
(SGMEAPICategories apiUser: 'your_sendgrid_username' apiKey:'your_sendgrid_password')
list: 'foobar'; get.
count
(SGMEAPICategories apiUser: 'your_sendgrid_username' apiKey:'your_sendgrid_password')
list: 'foobar'; count.
delete
(SGMEAPICategories apiUser: 'your_sendgrid_username' apiKey:'your_sendgrid_password')
list: 'foobar';
email:'foobar@example.com';
delete.
Categories
(SGMEAPICategories apiUser: 'your_sendgrid_username' apiKey:'your_sendgrid_password') list.
