Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2014
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. //require sendgrid
  2. require "sendgrid/sendgrid-php.php";
  3.  
  4. //sendMail function
  5. function sendMail($to, $subject, $content, $from){
  6.  
  7. //init sendgrid and email
  8. $sendgrid = new SendGrid("my_username", "my_password");
  9. $email = new SendGridEmail();
  10.  
  11. //to address = individual or array
  12. if (is_array($to)) $email->setTos($to);
  13. else $email->addTo($to);
  14.  
  15. //from, subject, contet
  16. $email->setFrom($from)->
  17. setSubject($subject)->
  18. setHtml($content);
  19.  
  20. //send email
  21. $sendgrid->send($email);
  22. }
  23.  
  24. sendMail("to@example.com", "Subject", "Content", "from@example.com");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement