Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Catch "413 Request Entity Too Large" error #27

Open
zhil opened this issue Mar 19, 2021 · 1 comment
Open

Catch "413 Request Entity Too Large" error #27

zhil opened this issue Mar 19, 2021 · 1 comment

Comments

@zhil
Copy link

zhil commented Mar 19, 2021

When you send too large email - you get error in logs.
How can it be catched correctly in code?

Sample code

$message =
            (new \Swift_Message('app:test:email'))
                ->setTo('[email protected]')
                ->setFrom($this->mailerSenderEmail, $this->mailerSenderName)
                ->setBody('test', 'text/plain');
        $message->attach((new \Swift_Attachment())
            ->setFilename('test.pdf')
            ->setBody(str_pad('', 30000000, '1'))
        );

        $result = $this->mailer->send($message);
        $output->writeln('Done! - '.$result);

зображення

@moux2003
Copy link
Collaborator

Since Symfony now have improved his mailer component, I suggest to take a look at https://symfony.com/doc/current/mailer.html#using-a-3rd-party-transport to see if it fits your needs.

Otherwise, I think you can just get an error from the event Swift_Events_SendEvent::RESULT_FAILED but no details attached.
Hope this helps a bit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants