Trying to use Sendgrid's API (running on bluemix) to send automated emails.
$sendgrid_username = 'XXXXXXXXX';
$sendgrid_password = 'XXXXXXXXXXXXXXX';
$to = $_SESSION['emailto'];
$from = "XXXXXXXXXXX@XXXX.com";
$sendgrid = new SendGrid($sendgrid_username, $sendgrid_password, array("turn_off_ssl_verification" => true));
$email = new SendGrid\Email();
$email->addTo($to)->
setFrom($from)->
setSubject('Password Reset')->
setHtml("<b>A new password has been set for the user: %mailto%.<br> The new password is: %pass%<br><br></b>")->
addSubstitution("%mailto%", array($_SESSION['emailto']))->
addSubstitution("%pass%", array($random_pass_clear))->
addHeader('X-Sent-Using', 'SendGrid-API')->
addHeader('X-Transport', 'web')->
$response = $sendgrid->send($email); //this is line 21
I've used the example code from Sendgrid and everything is working (email i being sent). I do however get 2 errors:
PHP NOTICE: Undefined Variable response on line 21
PHP FATAL ERROR: Cannot access empty property on line 21
I've never encountered the second error before and I'm kind of confused as to what is going on... any idea's where I went wrong?