Closed ebisbe closed 9 years ago
Good morning @ebisbe ,
First of all, thank you for your interest in Mailjet!
Now, regarding your issue, the problem probably comes from the fact that this version of the wrapper, while functional, is still under development and is tied to our pre production environment for some of its features.
However, depending on what you were trying to access, there might still be an issue with it.
In that regard, could you copy paste your code in your reply?
Hello @Gormador, I need to use namespace for a better load of the class and after looking throught the repository I found that branch that had the namespace and some rework so I wanted to give if a try. I saw at packagist that there wasn't any 2.0.0 so I tried directly the dev-sboo-master.
I was trying to make a simple send message. The error I got was 405 method not allowed. But neither POST nor GET work.
function actionIndex()
{
$response = '';
if (!empty(Yii::$app->request->post('to')) && !empty(Yii::$app->request->post('message'))) {
$params = array(
"method" => "POST",
"from" => "info@email.info",
"to" => Yii::$app->request->post('to'),
"subject" => "Hello World!",
"html" => Yii::$app->request->post('message')
);
Yii::$app->mailjet->sendEmail($params);
if (Yii::$app->mailjet->_response_code == 200) {
$response = "success - email sent";
} else {
$response = "error - " . Yii::$app->mailjet->_response_code;
Yii::$app->mailjet->debug();
}
}
return $this->render('index', ['response' => $response]);
}
The only difference from one branch to another is _response_code -> responseCode()
It is intended that you can't install it the "normal" composer way (specifying a version number), as this version isn't completely supported by our production API and shouldn't be available via a sloppy version specifier.
Regarding your issue, could you please also include the part where you initialise $app->mailjet
, as well as the one where you include the wrapper? Basically, everything related to the wrapper ;-)
Thanks in advance!
I set it up as a service locator in the yii configuration
<?php
use Mailjet\API\Client as Mailjet;
return [
'components' => [
'db' => [
'class' => 'yii\db\Connection',
'dsn' => 'pgsql:host=localhost;dbname=yii_test',
'username' => 'yii_test',
'password' => 'yii_test',
'charset' => 'utf8',
],
'mailer' => [
'class' => 'yii\swiftmailer\Mailer',
'viewPath' => '@common/mail',
// send all mails to a file by default. You have to set
// 'useFileTransport' to false and configure a transport
// for the mailer to send real emails.
'useFileTransport' => true,
],
'mailjet' => function() {
$apiKey = 'blabla';
$secretKey = 'bl4bl4';
$mj = new Mailjet($apiKey, $secretKey);
return $mj;
}
],
'params' => [
]
];
If you want we can do a few more sends and check the logs in your systems.
Hi @ebisbe ,
Sorry for the delay on my reply.
There is a bug introduced in the in-dev wrapper version you are using. It should be fixed now.
Let me know if your issue isn't resolved. If it is, please feel free to close it :-)
Working! Thanks for the feedback.
We just released a new PHP API wrapper. It is now more PHP-ish (including namespace, PSR-0 compliance, and globally a better architecture). All it requires is PHP 5.4
In addition to our API Guides, we would be happy to help you get started with it.
Guillaume, from Mailjet!
Hello, I've installed: "mailjet/mailjet-apiv3-php-simple": "dev-sboo-master" but I got an Method not allowed 405. Whenever I change to "mailjet/mailjet-apiv3-php-simple": "1.0.4" all emails are sent fine. What's the problem?