SendGrid API Libraries for Smalltalk
Switch branches/tags
Clone or download
Pull request Compare This branch is 11 commits ahead of newapplesho:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
pharo-repository
.gitignore
.smalltalk.ston
.travis.yml
LICENSE
README.md

README.md

SendGrid Smalltalk Build Status

SendGrid API Library to send emails very easily using Pharo Smalltalk. You can get started in minutes using Metacello and FileTree.

Features

Requirement

Smalltalk

  • Pharo 4.0, 5.0, 6.0, 6.1

How to install

Metacello new
    baseline: 'SendGrid';
    repository: 'github://sorabito/sendgrid-smalltalk/pharo-repository';
    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.

or

mail := SGMail default.
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.

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.