Page 1 of 1

no from or to in Swift_Events_BeforeSendListener

Posted: Wed May 28, 2008 9:09 pm
by n2breed
Hey,

I'm writing a plugin that implements Swift_Events_BeforeSendListener to pipe $e->getMessage()->build()->readFull() to spamassassin but the headers are not complete and I need a snapshot of the final message to score it properly.

During execution of beforeSendPerformed() the To, From and Message ID are blank:

Code: Select all

 
To: 
From: 
Subject: My stuff
Date: Thu, 29 May 2008 12:01:30 +1000
X-LibVersion: 3.3.2
MIME-Version: 1.0
etc.
 
Is there way to get a full render of the message + headers before it's sent?

Cheers..!

Re: no from or to in Swift_Events_BeforeSendListener

Posted: Wed May 28, 2008 9:29 pm
by Chris Corbyn
Ah yes, that's a problem really. Swift adds those headers immediately before sending the message, but apparently not before the beforeSendPerformed() method is used. It'd require some modification of the send() method inside the Swift class to change that.

Re: no from or to in Swift_Events_BeforeSendListener

Posted: Wed May 28, 2008 9:39 pm
by n2breed
Right ! well I had a look at that.. it's just before the headers are set! So close yet so far .. Maybe I'll do something external to swift for this bit .. However the manual needs an update near:
"BeforeSendListener is run before the message gets sent. You will know who the recipients are and what the message is at this stage, ... and so on .."

http://www.swiftmailer.org/wikidocs/v3/ ... esendevent
Thanks heaps for your help.. :wink:

Re: no from or to in Swift_Events_BeforeSendListener

Posted: Wed May 28, 2008 10:03 pm
by Chris Corbyn
n2breed wrote:Right ! well I had a look at that.. it's just before the headers are set! So close yet so far .. Maybe I'll do something external to swift for this bit .. However the manual needs an update near:
"BeforeSendListener is run before the message gets sent. You will know who the recipients are and what the message is at this stage, ... and so on .."

http://www.swiftmailer.org/wikidocs/v3/ ... esendevent
Thanks heaps for your help.. :wink:
$event->getRecipients();

That returns a RecipientList instance.

Re: no from or to in Swift_Events_BeforeSendListener

Posted: Wed May 28, 2008 10:37 pm
by n2breed
Chris Corbyn wrote:
$event->getRecipients();

That returns a RecipientList instance.
And then how would I render a raw message from there?

Re: no from or to in Swift_Events_BeforeSendListener

Posted: Wed May 28, 2008 11:16 pm
by Chris Corbyn

Code: Select all

$message->setTo($recipients->getTo());
// etc etc...
It's not very elegant though since once you've done that you then need to setTo(null) before the end of the method otherwise Swift will not do it's own natural set of replacements in the Headers.