0
votes

For last few hours I have been trying to send signed mail using swiftmailer via sendgrid SMTP server I'm successful with sending signed text emails but when I try to send html content in email sendgrid changes something and the signature becomes invalid any idea how to dump email before sending to know what is wrong? Or how to fix it?

PS: I have already disabled tracking pixel and it works with amazon.

Mailer config:

        $this->transport = Swift_SmtpTransport::newInstance($config['host'], 587, 'tls')
        ->setUsername($config['key'])
        ->setPassword($config['secret']);
    $this->mailer = \Swift_Mailer::newInstance($this->transport);

Message:

        $message = Swift_Message::newInstance($subject)
        ->setFrom(array($from => $from))
        ->setTo(array($receiver => $receiver));

Signer:

        $smimeSigner = new \Swift_Signers_SMimeSigner();
    $smimeSigner->setSignCertificate(env("S_MIME_CERT"), [env("S_MIME_KEY"), env("S_MIME_PASS")]);
    $message->attachSigner($smimeSigner);

Sending:

$sent = $this->mailer->send($message);
1
Hi Oskyk, could you show some example code you're using now? - Ronnie Oosting
@RonnieOosting edited question with code snippets - Oskyk
Try pre var_dump $message/$subject before and after Swift_Message. Any differences? - Ronnie Oosting
@RonnieOosting no luck - Oskyk
Which variable is going wrong? - Ronnie Oosting

1 Answers

1
votes

Fixed. Problem was that sendgrid uses different separators and they were replacing LF to CR LF so I changed all separators to CR LF before sending