2013-02-17 135 views
1

我在SendHrid中添加了基本版本的Heroku,以便我们可以从我们的网站发送用户反馈电子邮件。我使用的基本测试实现如下:Sendgrid/PHP/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('[email protected]')-> 
    setFrom('[email protected]')-> 
    setSubject('another')-> 
    setText('Hello World!')-> 
    setHtml('<strong>Hello World!</strong>'); 

$sendgrid-> 
    smtp-> 
    send($mail); 

header('Location: contact.html'); 

?> 

它在本地主机测试中工作正常。但是,当我在线测试时,它会停止。有没有人遇到过这样的问题?

+0

你能给你遇到问题的一些细节?如果你在你的代码的重要事件周围放置一些'echo'声明,你看到了什么? (需要,实例化,发送等)。你确定你的凭据是正确的吗?请求是否真的超时? – Swift 2013-02-18 00:24:14

+0

我把所有的文件放在我的heroku_upload文件夹中。 sendgrid目录已提交,但不包含内容。当我尝试添加像'git add sendgrid-php/*'时,我得到'致命的:路径'sendgrid-php/MIT.LICENSE'在子模块'sendgrid-php'中。我不认为我正确处理子模块。我在SendGrid_loader.php中加入了一个'echo',并试图将它包含在我的索引页中,但它没有显示任何内容。 – user1114864 2013-02-20 01:07:01

回答

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" 
+0

遵循doc过程,它结束了工作,但我认为这就是我正在做的。显然我不是,现在我正在收到电子邮件。谢谢! – user1114864 2013-02-20 18:35:38

+0

没问题,很高兴你明白了! – Swift 2013-02-21 03:50:45