mailgun,guzzle卷曲错误

尝试使用mailgun附加文件时出现此错误。</ p>

  致命错误:未捕获异常'Guzzle \ Http \ Exception \ CurlException',消息'[curl] 26:无法打开文件“zzz.txt”[url] https://api.mailgun.net/v2/ 沙箱8df78f0cdbc646aeb2a46999a8c6def5.mailgun.org/messages'在C:\ xampp \ htdocs \ tutlage 
ewsletter \ vendor \ guzzle \ guzzle \ src \ Guzzle \ Http \ Curl \ CurlMulti.php:359堆栈跟踪:#0 C:\ xampp \ htdocs \ tutlage
ewsletter \ vendor \ guzzle \ guzzle \ src \ Guzzle \ Http \ Curl \ CurlMulti.php(292):Guzzle \ Http \ Curl \ CurlMulti-&gt; isCurlException(Object(Guzzle \ Http \ Message \ EntityEnclosingRequest),Object (Guzzle \ Http \ Curl \ CurlHandle),数组)#1 C:\ xampp \ htdocs \ tutlage
ewsletter \ vendor \ guzzle \ guzzle \ src \ Guzzle \ Http \ Curl \ CurlMulti.php(257):Guzzle \ Http \ Curl \ CurlMulti-&gt; processResponse(Object(Guzzle \ Http \ Message \ EntityEnclosingRequest),Object(Guzzle \ Http \ Curl \ CurlHandle),Array)#2 C:\ xampp \ htdocs \ tutlage
ewsletter \ vendor \ guzzle \ guz zle \ src \ Guzzle \ Http \ Curl \ CurlMulti.php(240):Guzzle \ Http \ Curl \ CurlMulti-&gt; processMessages()#3 C:\ xampp \ htdocs \ tutlage
ewsletter \ vendor \ guzzle \ guzzle \ src \ Gzzle \ Http \ Curl \ C in C:\ xampp \ htdocs \ tutlage
ewsletter \ vendor \ guzzle \ guzzle \ src \ Guzzle \ Http \ Curl \ CurlMulti.php 359行
</ code> </ pre>

如何解决此问题?
这是一个guzzle证书问题吗?</ p>

我附加了这样的文件(这里没有错)(文件可以通过php访问): </ p>

  $ mg-&gt; sendMessage($ domain,array('from'=&gt;  '...',
'到'=&gt; '...',
'subject'=&gt; '...',
'text'=&gt; '...'
),array(
'attachment'=&gt; array('zzz.txt')

);
</ code> </ pre>
</ div>

展开原文

原文

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个回答



显然,在当前目录中找不到文件 zzz.txt </ code>,你应该指定它的位置 绝对或相对,例如,使用 __ DIR __ </ code>常量:</ p>

  $ mg-&gt; sendMessage(
$ domain,
array(

'从'=&gt;'...',
'到'=&gt;'...',
'subject'=&gt;'...',
'text'=&gt; '...',
),
数组(
'attachment'=&gt;数组(
DIR。'/ foo / bar / zzz.txt',
),
),
) ;
</ code> </ pre>

供参考,请参阅 http://php.net/manual/en/language.constants.predefined.php 。</ p>
</ div>

展开原文

原文

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.

duanqinbi9029
duanqinbi9029 谢谢(Windows的反斜杠)
4 年多之前 回复



这对我有用。 请尝试以下代码</ p>

  define('ROOTPATH',dirname(__ FILE __)); 
$ filePath = ROOTPATH。'/ textfile.txt';
$ result = $ mgClient-&gt; sendMessage(“$ domain”,
array('from'=&gt;'从地址',
'到'=&gt;'到addreess',
'subject'=&gt;'查找附件 ',
'html'=&gt;'&lt; h2&gt; HTML&lt; / h2&gt;'),
array('attachment'=&gt; array($ filePath)));
</ code> </ pre >
</ div>

展开原文

原文

It's works good for me. Try the following code

define('ROOTPATH', dirname(__FILE__));
$filePath = ROOTPATH.'/textfile.txt';
$result = $mgClient->sendMessage("$domain",
    array('from'    => 'from address',
        'to'      => 'to addreess',
        'subject' => 'Find Attachment',         
        'html'    => '<h2>HTML</h2>'),
    array('attachment' => array($filePath)));

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐