Skip to content

[Mime] Line endings not correct when using S/MIME and Linux #36398

@TokkCorp

Description

@TokkCorp

Symfony version(s) affected: 5.0+

Description
When sending mails using the symfony mailer the line endings in the message to the mailserver are missing the carriage return if S/MIME encryption is used on a linux server.

I've prepared four examples of what gets send to the mailserver:

Because of the wrong endings sending huge files leads to the following error:
PHP Fatal error: Uncaught Symfony\Component\Mailer\Exception\TransportException: Expected response code "250" but got code "501", with message "501 Syntax error - line too long". in /example/vendor/symfony/mailer/Transport/Smtp/SmtpTransport.php:298

How to reproduce
The Problem will occur always when sending an S/MIME encrypted Mail like this:

$email = (new Email())
    ->from('sender@example.com')
    ->to('recipient@example.com')
    ->subject('Encrypted mail with attachment')
    ->attachFromPath('./attachments/LoremIpsum.pdf')
    ->text(fopen('./attachments/content.txt', 'r'))
    ->html(fopen('./attachments/content.html', 'r'));

$encrypter = new SMimeEncrypter('./cert/smime.cer');
$encryptedEmail = $encrypter->encrypt($email);

The wrong line endings are also present without an attachment but the server error will occure only if the message is long enough to exceed the maximal line length.

Possible Solution
Fix the line endings in S/MIME encrypted messages.

Additional Information
It is working using Swiftmailer on the same systems so I would conclude the error is in the mailer component and not in openssl or any other system.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions