hack princeton
DESCRIPTION
TRANSCRIPT
Hack Princeton
Kunal BatraDeveloper Evangelist
11/08/13
What is SendGrid ?
• Cloud based SMTP email Provider– Transactional: Registration, forgotten
passwords, account notifications.
• Massively Scalable• Analytics on the emails you send
– Unsubscribes, bounces …etc.
Why not build it myself ?
• Focus on your core application
• Maintaining Email Infrastructure Sucks!– Costly, Time-consuming, Boring!!
• 20% of legitimate email goes to spam
Some of our APIs
• SMTP API• Web API• Parse Webhook (Cool!)• Event Webhook
Take a Photo
Parse Data from email
//Get Post from SendGrid
$from = $_POST["from"];$subject = $_POST["subject"];
//Get Attached Image $fh = fopen('/tmp/parse.log', 'a+');if ( $fh ) { fwrite($fh, print_r($_POST, true) . print_r($_FILES, true)); foreach ($_FILES as $key => $file) { move_uploaded_file($file['tmp_name'], "upload/".$file['name']); } fclose($fh); }
Convert Photo to text
$ocrapi = new Abby($config['abby']['app_id'], $config['abby']['password']);$docName = $ocrapi->convert($file['name']);
Send reply email//Send reply email with attached text document $filePath = dirname(__FILE__).'/upload/'.$docName;$sendgrid = new SendGrid($config['sendgrid']['api_user'], $config['sendgrid']['api_key']);
$mail = new SendGrid\Mail();
$mail-> addTo($from)-> setFrom($config['sendgrid']['my_email'])-> setSubject('Re: '.$subject)-> setText($docName)-> setHtml($docName)-> addAttachment($filePath);
$sendgrid->smtp->send($mail)
Awesome Prizes- Retro NES/SNES Game Systems
Ouya Gaming Console
Mortal Kombat- 1993
Assorted NES Games
Hack.Sendgrid.com
GO TOHack.Sendgrid.comSign up for a FREE account &&Tweet @kunal732 with your SendGrid username to get setup.