Skip to content

Instantly share code, notes, and snippets.

@kunal732
Created August 6, 2013 10:17
Show Gist options
  • Save kunal732/6163357 to your computer and use it in GitHub Desktop.
Save kunal732/6163357 to your computer and use it in GitHub Desktop.
//convert body to image
$imageUrl= file_get_contents("http://api.img4me.com/?text=".$urlbody."&font=arial&fcolor=000000&size=10&bcolor=FFFFFF&type=png");
$imgName = $emailID.".png";
file_put_contents('img/'.$imgName, file_get_contents($imageUrl));
//html body to show
$htmlbody = "<img src=\"http://magicmail.io/img/".$imgName."\" />";
$sendgrid = new SendGrid($config['sendgrid']['api_user'], $config['sendgrid']['api_key']);
$mail = new SendGrid\Mail();
$mail->
addTo($to)->
setFrom($from)->
setSubject($subject)->
addUniqueArgument("filename", $imgName)->
setText($htmlbody)->
setHtml($htmlbody);
$sendgrid->smtp->send($mail);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment