Skip to content

Instantly share code, notes, and snippets.

@typerandom
Created March 29, 2013 23:24

Revisions

  1. typerandom created this gist Mar 29, 2013.
    18 changes: 18 additions & 0 deletions alphamail-node-js-example.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    var alphamail = require('alphamail');
    var emailService = new alphamail.EmailService("API-TOKEN");

    var data = {name:"Joe", pwns:true, likesCats:"certainly"};
    var payload = new alphamail.EmailMessagePayload()
    .setProjectId(1235) // ID of your AlphaMail project
    .setSender(new alphamail.EmailContact("My Company", "your@domain.com"))
    .setReceiver(new alphamail.EmailContact("Some dude", "receiver@some55-domain.com"))
    .setBodyObject(data);

    emailService.queue(payload, function(error, result){
    if(error){
    console.log(error);
    return;
    }

    console.log("Email sent! ID = " + result);
    });