message signing
Moderators: Chris Corbyn, General Moderators
message signing
Hi,
I am using swift for sending e-mails from our accounting system and we now need to sign outgoing messages (we have been doing this in the past using openssl_pkcs7-sign PHP function) - can we somehow sign outgoing messages when sending them via swiftmailer?
Thanks, Tom.
I am using swift for sending e-mails from our accounting system and we now need to sign outgoing messages (we have been doing this in the past using openssl_pkcs7-sign PHP function) - can we somehow sign outgoing messages when sending them via swiftmailer?
Thanks, Tom.
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
I'm not sure how message signing works, but you are going to do you'd write a BeforeSendListener plugin to grab the message before it's sent then sign it. I can probably write an extension to Swift_Message too... something like Swift_SignedMessage. I'll look into how it works, or if you want to brief me on it that would be good 
Well, I myself am not an expert on message signing, the code we've been using was written by someone who does not work in our company anymore. But, as I understand it, openssl_pkcs7_sign PHP function is used for message signing, and it should work like this:
Code: Select all
$text = 'test e-mail body';
$file = file_put_contents('signing.txt', $text);
openssl_pkcs7_sign('signing.txt',
'signed.txt',
'file://openssl/certifikat2006az7.pem',
'file://openssl/private_key2006az7.pem',
array());
$data = file_get_contents('signed.txt');
$parts = explode("\n\n", $data, 2);
$parts[0] .= "\nFrom: test <tomas.kejzlar@gmail.com>\n";
mail('somebody@somewhere', 'test', $parts[1], $parts[0]);- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
Unless you consider my confuddled few lines of experimentation a start, I'm basically where I was last time I posted
Code: Select all
$message = new Swift_Message("My subject");
$message->setBody("my message");
/*$part1 = new Swift_Message_Part("some part");
$message->attach($part1);
$part2 = new Swift_Message_Part("another_aprt", "text/html");
$message->attach($part2);*/
$message->setTo(array(new Swift_Address("cac@parrswood.manchester.sch.uk"), new Swift_Address("chris@iris.ac")));
$message->setFrom("chris@w3style.co.uk");
$stream = $message->buildData();
$fp = fopen("signed/unsigned.txt", "w");
fwrite($fp, $stream->readFull());
fclose($fp);
echo file_get_contents("signed/unsigned.txt");
echo "===================================";
openssl_pkcs7_sign("signed/unsigned.txt", "signed/signed.txt", "file://mycert.pem", array("file://mykey.pem", "swiftmailer"), array("From: <chris@w3style.co.uk"), OPENSSL_KEYTYPE_RSA);
echo file_get_contents("signed/signed.txt");Sorry about that.
Thanks for the reminder. I should add it to the TODO file really.
Re: message signing
Hi, I try to find any possibility to sign S/MIME e-mails via PHP, but I found nothing. Do you know any ideas?
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
Re: message signing
It's going to be in the enterprise edition of Swift Mailer version 4. The enterprise edition will be a paid download however.
Re: message signing
Ok, I would buy it, when it will be?
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
Re: message signing
The short answer is "I don't have an accurate ETA", but you may wish to subscribe to this thread:
viewtopic.php?f=52&t=81467
viewtopic.php?f=52&t=81467