doumi1912 2015-12-28 16:49
浏览 50
已采纳

mailgun,guzzle卷曲错误

I have this error when trying to attach a file with mailgun.

Fatal error: Uncaught exception 'Guzzle\Http\Exception\CurlException' with message '[curl] 26: couldn't open file "zzz.txt" [url] https://api.mailgun.net/v2/sandbox8df78f0cdbc646aeb2a46999a8c6def5.mailgun.org/messages' in C:\xampp\htdocs\tutlage
ewsletter\vendor\guzzle\guzzle\src\Guzzle\Http\Curl\CurlMulti.php:359 Stack trace: #0 C:\xampp\htdocs\tutlage
ewsletter\vendor\guzzle\guzzle\src\Guzzle\Http\Curl\CurlMulti.php(292): Guzzle\Http\Curl\CurlMulti->isCurlException(Object(Guzzle\Http\Message\EntityEnclosingRequest), Object(Guzzle\Http\Curl\CurlHandle), Array) #1 C:\xampp\htdocs\tutlage
ewsletter\vendor\guzzle\guzzle\src\Guzzle\Http\Curl\CurlMulti.php(257): Guzzle\Http\Curl\CurlMulti->processResponse(Object(Guzzle\Http\Message\EntityEnclosingRequest), Object(Guzzle\Http\Curl\CurlHandle), Array) #2 C:\xampp\htdocs\tutlage
ewsletter\vendor\guzzle\guzzle\src\Guzzle\Http\Curl\CurlMulti.php(240): Guzzle\Http\Curl\CurlMulti->processMessages() #3 C:\xampp\htdocs\tutlage
ewsletter\vendor\guzzle\guzzle\src\Guzzle\Http\Curl\C in C:\xampp\htdocs\tutlage
ewsletter\vendor\guzzle\guzzle\src\Guzzle\Http\Curl\CurlMulti.php on line 359

How to fix this ? Is it a guzzle certificate issue ?

I attach the file like this (nothing wrong here) (file is accessible by php) :

$mg->sendMessage($domain, array('from'    => '...',
                                'to'      => '...',
                                'subject' => '...', 
                                'text'    => '...'
                                ), array(
                                    'attachment' => array('zzz.txt')
                                )
);
  • 写回答

2条回答 默认 最新

  • dongqian1925 2015-12-31 17:03
    关注

    Apparently, the file zzz.txt could not be found in the current directory, you should specify it's location either absolute or relative, for example, using the __DIR__ constant:

    $mg->sendMessage(
        $domain, 
        array(
            'from' => '...',
            'to' => '...',
            'subject' => '...', 
            'text' => '...',
        ), 
        array(
            'attachment' => array(
                __DIR__ . '/foo/bar/zzz.txt',
            ),
        ),
    );
    

    For reference, see http://php.net/manual/en/language.constants.predefined.php.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题