【问题标题】:Sendgrid/PHP/Heroku Not WorkingSendgrid/PHP/Heroku 不工作
【发布时间】:2013-02-17 21:57:08
【问题描述】:

我将 SendGrid 的基本版本添加到 Heroku,以便我们可以从我们的网站发送用户反馈电子邮件。我正在使用的基本测试实现如下:

<?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' );

?>

它在 localhost 测试中运行良好。但是,当我在线测试时,它会停止。有人遇到过这样的问题吗?

【问题讨论】:

  • 您能否详细说明您遇到的问题?如果您在代码中的重要事件周围放置一些echo 语句,您会看到什么? (要求、实例化、发送等)。您确定您的凭据正确吗?请求是否真的超时了?
  • 我把所有的文件都放在了我的 heroku_upload 文件夹中。 sendgrid 目录已提交,但内容未提交。当我尝试像git add sendgrid-php/* 这样添加时,我得到fatal: Path 'sendgrid-php/MIT.LICENSE' is in submodule 'sendgrid-php'。我认为我没有正确处理子模块。我在 SendGrid_loader.php 中添加了 echo 并尝试将其包含在我的索引页面中,但它没有显示任何内容。

标签: heroku directory sendgrid


【解决方案1】:

听起来您在 Heroku 上的子模块存在一些问题。有两种方法可以解决此问题:

1) 通过阅读heroku submodule docs 找出您做错了什么。大概就这么简单git submodule add path/to/sendgrid

2) 删除 SendGrid 模块中的 .git 目录并将其签入您的存储库:

$ 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"

【讨论】:

  • 遵循文档程序,它最终工作了,尽管我认为这就是我正在做的事情。显然我不是,现在我收到了电子邮件。谢谢!
  • 没问题,很高兴你明白了!
猜你喜欢
  • 2020-01-13
  • 1970-01-01
  • 2013-01-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-05-20
  • 2012-05-23
  • 1970-01-01
相关资源
最近更新 更多