Closed ndijkstra closed 1 year ago
I'll take a look at the issue. Is it possible for you to provide the code for your Mailable class or API request payload if you're using the Facade.
Thanks for your swift reply! Is this enough for you?
$mailer->send('emails.empty', [
'msg' => $this->data['message'],
'subject' => $this->data['subject'],
'fromName' => $this->data['fromName'],
'logo' => ($this->data['logo'] ?? null) !== null ? Storage::url($this->data['logo']) : null,
'locale' => $this->data['locale'] ?? null,
], function ($m) {
$m->from($this->data['fromEmail'], $this->data['fromName']);
$email = explode(',', $this->data['email']);
$m->to(trim($email[0]), $this->data['name'])->subject($this->data['subject']);
if (isset($this->data['replyToEmail']) && $this->data['replyToEmail']) {
$m->replyTo($this->data['replyToEmail'], $this->data['replyToName'] ?? null);
}
});
This is perfect thanks! Give me a day or two while I look into this for you. I think you might also be able to refactor this code to be more readable. I'll update you soon.
@ndijkstra I wasn't able to reproduce the error on my end. Could you please send through some dummy data for $this->data
that fails?
I see there are some 422 errors visible in the Resend logs. It should have thrown that exception, instead of this error about null passing in the header.
Response body:
{
"statusCode": 422,
"name": "invalid_parameter",
"message": "Invalid `from` field. The email address needs to follow the `email@example.com` or `Name <email@example.com>` format"
}
You're absolutely right about the error being returned as an exception. I actually already have a fix for that waiting for review: https://github.com/resendlabs/resend-php/pull/35
@bukinoshita could you please review the above PR as soon as you can. ❤️
@ndijkstra could you please try reinstall resend/resend-laravel
and ensure that resend/resend-php
0.7.2
is installed? This will fix the invalid_parameter
exception issue.
I'm getting this error from time to time:
Symfony\Component\Mime\Header\Headers::addTextHeader(): Argument #2 ($value) must be of type string, null given, called in /vendor/symfony/mime/Header/Headers.php on line 152
This is triggered by
vendor/resend/resend-laravel/src/Transport/ResendTransportFactory.php: 66