<?php /* * SendPulse REST API Usage Example * * Documentation * https://login.sendpulse.com/manual/rest-api/ * https://sendpulse.com/api */ require_once 'api/sendpulseInterface.php'; require_once 'api/sendpulse.php'; // https://login.sendpulse.com/settings/#api define('API_USER_ID', ''); define('API_SECRET', ''); define('TOKEN_STORAGE', 'file'); $SPApiProxy = new SendpulseApi(API_USER_ID, API_SECRET, TOKEN_STORAGE); // Get Mailing Lists list example var_dump($SPApiProxy->listAddressBooks()); // Send mail using SMTP $email = array('html' => '<p>Hello!</p>', 'text' => 'text', 'subject' => 'Mail subject', 'from' => array('name' => 'John', 'email' => '*****@*****.**'), 'to' => array(array('name' => 'Client', 'email' => '*****@*****.**')), 'bcc' => array(array('name' => 'Manager', 'email' => '*****@*****.**'))); var_dump($SPApiProxy->smtpSendMail($email));
function send_mail($email, $subject, $text) { $SPApiProxy = new SendpulseApi(SENDPULSE_API_USER_ID, SENDPULSE_API_SECRET, "session"); $email = ['html' => $text, 'text' => strip_tags($text), 'subject' => $subject, 'from' => ['name' => SENDPULSE_FROM_NAME, 'email' => SENDPULSE_FROM_EMAIL], 'to' => [['name' => $email, 'email' => $email]]]; return $SPApiProxy->smtpSendMail($email)->result; }