Sendgrid/PHP/Heroku Not Working

。_饼干妹妹 提交于 2019-12-11 09:54:49

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!