php - Mailgun : Fatal error: Uncaught exception 'Guzzle\Common\Exception\InvalidArgumentException' with message 'Unable to open -
i have used following code , have placed these files in same directory of script running send mail. exception continues thrown when try give online link.
i trying piece of php code in local host can figure out error below
# include autoloader (see "libraries" install instructions) require 'mail/vendor/autoload.php'; use mailgun\mailgun; # instantiate 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'))));
fatal error: uncaught exception 'guzzle\common\exception\invalidargumentexception' message 'unable open /file.txt reading' in c:\xampp\htdocs\zendeskapis\mail\vendor\guzzle\guzzle\src\guzzle\http\message\postfile.php:53 stack trace: #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\zendeskapis\mail\vendor\mailgun\mailgun-php\ in c:\xampp\htdocs\zendeskapis\mail\vendor\guzzle\guzzle\src\guzzle\http\message\postfile.php on line 53
as exception state it, file path doesn't seem correct.
assuming you're on nix system, file.txt should right under / seems quite unlikely me.
if you're on windows system path /file.txt
not have meaning.
try hardcode first path, once work set dynamically
Comments
Post a Comment