mailjet / mailjet-apiv3-php

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

How to debug ? #253

Closed S-Umair closed 2 years ago

S-Umair commented 2 years ago

How can one debug the client when all the request is returning as successful ?

code:

    public function send(string $to, int $templateID, string $subject, $variable = null): ?bool
    {
        $mailjet = new Client(
            $this->container->getParameter('sender_mail_key'),
            $this->container->getParameter('sender_mail_secret'),
            true,
            ['version' => 'v3.1']
        );
        $mailjet->setTimeout(10000);
        $mailjet->setConnectionTimeout(10000);
        $body = [
            'Messages' => [
                [
                    'From' => [
                        'Email' => $this->container->getParameter('sender_mail'), 
                        'Name' => "Site Name"
                    ],
                    'To' => [
                        [
                            'Email' => $to,
                            'Name' => ''
                        ]
                    ],
                    'TemplateID' => $templateID,
                    'TemplateLanguage' => true,
                    'TemplateErrorReporting' => [
                        'Email'=> $this->container->getParameter('sender_mail'),
                        'Name'=> "Site Name"
                    ],
                    'Subject' => $subject,
                    'variables' => [
                        'var' => $variable
                    ]
                ]
            ]
        ];
        $response = $mailjet->post(Resources::$Email, ['body' => $body]);
         dd($response->getRequest(),  $response->success());
    }

output:

  -method: "POST"
  -url: "https://api.mailjet.com/v3.1/send"
  -filters: []
  -body: array:1 [▼
    "Messages" => array:1 [▼
      0 => array:7 [▼
        "From" => array:2 [▼
          "Email" => "support@site.com"
          "Name" => "site name"
        ]
        "To" => array:1 [▼
          0 => array:2 [▼
            "Email" => "support@site.com"
            "Name" => ""
          ]
        ]
        "TemplateID" => 3950692
        "TemplateLanguage" => true
        "TemplateErrorReporting" => array:2 [▼
          "Email" => "support@site.com"
          "Name" => "Site Name"
        ]
        "Subject" => "test"
        "variables" => array:1 [▼
            "var" => array:4 [▼
            "from" => "contact@syedumair.dev"
            "object" => "test"
            "context" => "test"
            "contact" => App\Entity\Contact {#1044 ▼
              -id: null
              -object: "test"
              -contenu: "test"
              -user: null
              -dateCreate: null
              -email: "contact@syedumair.dev"
            }
          ]
        ]
      ]
    ]
  ]
  -auth: array:2 [▼
    0 => "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
    1 => "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
  ]
  -type: "application/json"
  -requestOptions: array:2 [▼
    "timeout" => 10000
    "connect_timeout" => 10000
  ]
}
true // $response->success();
BenjaminPorquet commented 2 years ago

Personnaly i use $response->getData() for debug

oleksandr-mykhailenko commented 2 years ago

@S-Umair You can use print_r for $response What actually do you want to debug ? Maybe some specific ?

S-Umair commented 2 years ago

@oleksandr-mykhailenko The issue is that API is returning successful even if the domain is not verified.

oleksandr-mykhailenko commented 2 years ago

@S-Umair So, I want to understand your problem. Why this is issue for you ? Successful response itself is not only about that something was created or etc. I mean, even if domain is not verified it does not mean that the API should send you error messages. Maybe you want to check some specific setting ?

oleksandr-mykhailenko commented 2 years ago

close the issues because it's not an error and according to inactivity