Reputation: 123
I am sending an email individually with MAILCHIMP
without using templates
, but the return
comes out empty, what would be the correct way to send the request message?
-The answer returns
empty and the mail does not arrive
-This is my post method
route: http://localhost:6002/api/mailchimp/message/send
"message": [
{
"subject": "student",
"from_email": "[email protected]",
"html":"<p>Estudia en la UNI</p>",
"text": "Estudia en la UNI",
"to": [
{
"email": "[email protected]",
"type": "to"
}
]
}
]
}
function
public function send(Request $request)
{
$message = $request->message;
$mailchimp = new MailchimpTransactional\ApiClient();
$mailchimp->setApiKey(env('MAILCHIMP_KEY'));
$response = $mailchimp->messages->send(
[
"message"=>$message
]
);
return response()->json($response, 200);
}
PD: in another method I receive the post using templates there if it works => $respuesta = $mailchimp->messages->sendTemplate(...)
Upvotes: 0
Views: 676
Reputation: 123
I realized that in the json I send it has brackets []
, and it shouldn't go, it would look like this and it worked
"message": {
"subject": "student",
"from_email": "[email protected]",
"html":"<p>Estudia en la UNI</p>",
"text": "Estudia en la UNI",
"to": [
{
"email": "[email protected]",
"type": "to"
}
]
}
}
Upvotes: 0