At the top of my index.php file I have:
require('sendgrid-php/SendGrid_loader.php');
And at the bottom I use this code to send the email:
<?php
if(isset($_POST['submit']))
{
$sendgrid = new SendGrid('app11445063@heroku.com', 'password');
$mail = new SendGrid\Mail();
$mail->
addTo('email@gmail.com')->
setFrom('app11445063@heroku.com')->
setSubject('Subject goes here')->
setText('Hello World!')->
setHtml('<strong>Hello World!</strong>');
$sendgrid->
smtp->
send($mail);
}
?>
I can’t get the code to send an email out. I have the proper account from SendGrid and Heroku. The required files are in my directory. Do I have the wrong path to the required file?
The issue was that the SendGrid library was not in the repository in Heroku. Just do a “git status” and add the directory to the commit and then push the directory to Heroku. Make sure you also have the correct path in the “include” in your PHP code.