簡體   English   中英

Mailgun:致命錯誤:帶有消息“無法打開”的未捕獲異常“ Guzzle \\ Common \\ Exception \\ InvalidArgumentException”

[英]Mailgun : Fatal error: Uncaught exception 'Guzzle\Common\Exception\InvalidArgumentException' with message 'Unable to open

我使用了以下代碼,並將這些文件放置在與我正在運行的用於發送郵件的腳本相同的目錄中。 即使我嘗試提供在線鏈接,也仍然會引發異常。

我正在我的本地主機中嘗試這段PHP代碼,您可以從以下錯誤中找出答案

# Include the Autoloader (see "Libraries" for install instructions)
require 'mail/vendor/autoload.php';
use Mailgun\Mailgun;

# Instantiate the client.
$mgClient = new Mailgun('key-secret');
$domain = "mydomain";

    $result = $mgClient->sendMessage($domain, array(
    'from'    => 'email',
             'to'      => 'email',
             'bcc'     => 'email',
             'subject' => "Sending Attachment 2",
             'text'    => "Sending Attachment",
             'html'    => "Sending Attachment",
             'attachment-1'=> 'test.xml'
),  array("attachment" => array(
                                    array('filePath'   => '@/file.txt', 
                                          'remoteName' => 'file.txt'),
                                    array('filePath'   => '@/test.txt', 
                                          'remoteName' => 'test.txt'))));

致命錯誤:C:\\ xampp \\ htdocs \\ zendeskapis \\ mail \\ vendor \\ guzzle \\ guzzle \\ src \\ Guzzle \\ Http下未捕獲的異常'Guzzle \\ Common \\ Exception \\ InvalidArgumentException',消息為“無法打開/file.txt以供讀取” \\ Message \\ PostFile.php:53堆棧跟蹤:#0 C:\\ xampp \\ htdocs \\ zendeskapis \\ mail \\ vendor \\ guzzle \\ guzzle \\ src \\ Guzzle \\ Http \\ Message \\ PostFile.php(28):Guzzle \\ Http \\ Message \\ PostFile-> setFilename('@ / file.txt')#1 C:\\ xampp \\ htdocs \\ zendeskapis \\ mail \\ vendor \\ guzzle \\ guzzle \\ src \\ Guzzle \\ Http \\ Message \\ EntityEnclosingRequest.php(199):Guzzle \\ Http \\ Message \\ PostFile-> __ construct('attachment','@ / file.txt',NULL,'file.txt')#2 C:\\ xampp \\ htdocs \\ zendeskapis \\ mail \\ vendor \\ mailgun \\ mailgun-php \\ src \\ Mailgun \\ Connection \\ RestClient.php(52):Guzzle \\ Http \\ Message \\ EntityEnclosingRequest-> addPostFile('attachment','@ / file.txt',NULL,'file.txt')#3 C:\\ xampp \\ htdocs \\ zendeskapis \\ mail \\ vendor \\ mailgun \\ mailgun-php \\ src \\ Mailgun \\ Mailgun.php(80):Mailgun \\ Connection \\ RestClient-> post('hotelpalmshore ....',Array,Array)#4 C :\\ xampp \\ htdocs \\ zendesk 第53行上的C:\\ xampp \\ htdocs \\ zendeskapis \\ api \\ mail \\ vendor \\ mailgun \\ mailgun-php \\中的apis \\ mail \\ vendor \\ mailgun \\ mailgun-php \\\\ 53頁上的api \\ mail \\ vendor \\ guzzle \\ guzzle \\ src \\ Guzzle \\ Http \\ Message \\ PostFile.php

作為異常狀態,您的文件路徑似乎不正確。

假設您使用的是nix系統,則file.txt應該位於/下,這對我來說似乎不太可能。

如果您使用的是Windows系統,則/file.txt路徑沒有任何意義。

嘗試先對您的路徑進行硬編碼,一旦可以正常使用,請對其進行動態設置

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM