Mailgun没有到达最后一个echo / test语句(PHP / Ubuntu设置)

时间:2014-12-26 13:43:43

标签: php ubuntu mailgun

我是PHP的新手,正在尝试为Mailgun做一个Hello World,看看它是如何工作的。由于某种原因,最后两个echo未被调用,并且未发送电子邮件。请参阅下面的代码:

<?php

require 'vendor/autoload.php';  
use Mailgun\Mailgun;

# Instantiate the client.

$domain = //
echo("TEMP");


# Make the call to the client.
$mgClient = new Mailgun("key-###");
echo("TEMP");

$cont = array(
'from'    => 'Mailgun Sandbox <postmaster@sandboxc73bdba03d4f4a46a36c319de9e2c00e.mailgun.org>',
'to'      => 'ovadia <oharary@me.com>',
'subject' => 'Hello',
'text'    => 'Testing some Mailgun awesomness!'
 );


 $result=$mgClient->sendMessage($domain, $cont);

 echo("TEM2P");

 echo("TEM3P");

 ?>

错误日志:

[Fri Dec 26 13:31:49.740756 2014] [:error] [pid 17630] [client 73.197.216.144:49648] script '/var/www/html/temp.php' not found or unable to stat
[Fri Dec 26 13:33:02.652593 2014] [:error] [pid 18741] [client 73.197.216.144:49737] PHP Fatal error:  Uncaught exception 'Guzzle\\Common\\Exception\\RuntimeException' with message 'The PHP cURL extension must be installed to use Guzzle.' in /var/www/html/vendor/guzzle/guzzle/src/Guzzle/Http/Client.php:72\nStack trace:\n#0 /var/www/html/vendor/mailgun/mailgun-php/src/Mailgun/Connection/RestClient.php(28): Guzzle\\Http\\Client->__construct('https://api.mai...')\n#1 /var/www/html/vendor/mailgun/mailgun-php/src/Mailgun/Mailgun.php(26): Mailgun\\Connection\\RestClient->__construct('key-54065c15441...', 'api.mailgun.net', 'v2', true)\n#2 /var/www/html/temp.php(15): Mailgun\\Mailgun->__construct('key-54065c15441...')\n#3 {main}\n  thrown in /var/www/html/vendor/guzzle/guzzle/src/Guzzle/Http/Client.php on line 72

1 个答案:

答案 0 :(得分:3)

开始安装PHP curl:sudo apt-get install curl libcurl3 libcurl3-dev php5-curl。然后检查以确保您的脚本能够找到所有资源。您的堆栈跟踪中有一个错误,表明无法找到/var/www/html/temp.php。

然后sudo /etc/init.d/apache2 restart再次尝试您的代码。 祝你好运。