问题
I added the basic version of SendGrid to Heroku so we could send user-feedback emails from our website. The basic testing implementation I'm using is below:
<?php
/**** Takes posted content from 'contact.html' and sends us an email *****/
require 'sendgrid-php/SendGrid_loader.php';
$sendgrid = new SendGrid('username', 'pwd');
$mail = new SendGrid\Mail();
$mail->
addTo('matthewpolega@gmail.com')->
setFrom('matthewpolega@gmail.com')->
setSubject('another')->
setText('Hello World!')->
setHtml('<strong>Hello World!</strong>');
$sendgrid->
smtp->
send($mail);
header( 'Location: contact.html' );
?>
It works fine in localhost testing. However, it stalls when I test it online. Has anybody experienced a problem like this?
回答1:
It sounds like you're having some issues with submodules on Heroku. There are two ways you can fix this:
1) Figure out what you did wrong by reading the heroku submodule docs. It's probably as simple as git submodule add path/to/sendgrid
2) Remove the .git
directory in the SendGrid module and check it in to your repo:
$ cd ../path/to/sendgrid_lib
$ rm -rf .git/
$ cd ../root/project/dir
$ git add ../path/to/sendgrid_lib
$ git commit -m "Removed SendGrid submodule and added to repo"
来源:https://stackoverflow.com/questions/14926554/sendgrid-php-heroku-not-working