mailjet / mailjet-apiv3-php

[API v3] Mailjet PHP Wrapper
http://dev.mailjet.com
MIT License
267 stars 86 forks source link

Class "Mailjet\Client" not found #242

Closed ganiru closed 2 years ago

ganiru commented 2 years ago

I installed the library

composer require mailjet/mailjet-apiv3-php

and ran the following code on the Dreamhost server running PHP 8.1 (replaced XXXX with the appropriate keys)

<?php
  require 'vendor/autoload.php';
  use \Mailjet\Resources;
  $mj = new \Mailjet\Client('XXXX','XXXX',true,['version' => 'v3.1']);
  $body = [
    'Messages' => [
      [
        'From' => [
          'Email' => "joe@mail.com",
          'Name' => "Bob"
        ],
        'To' => [
          [
            'Email' => "joe@apple.com",
            'Name' => "Jack"
          ]
        ],
        'Subject' => "Greetings from Mailjet.",
        'TextPart' => "My first Mailjet email",
        'HTMLPart' => "<h3>Dear passenger 1, welcome to <a href='https://www.mailjet.com/'>Mailjet</a>!</h3><br />May the delivery force be with you!",
        'CustomID' => "AppGettingStartedTest"
      ]
    ]
  ];
  $response = $mj->post(Resources::$Email, ['body' => $body]);
  $response->success() && var_dump($response->getData());
?>

but I'm getting the error Fatal error: Uncaught Error: Class "Mailjet\Client" not found in /home/cccc/cccc/sendmj.php:9 Stack trace: #0 {main} thrown in /home/cccc/cccc/sendmj.php on line 9

It works fine when I run it locally on my Macbook Pro with PHP 8.0.8 What gives??