Re: smtp proxy to external smtp server

2011-05-20 Thread Jared Johnson
We do the sort of signing that is a huge doozy, and Matt is right, it's a
doozy :)  There are a couple of ways we've accomplished re-writing the
body from a MIME::Entity.  Honestly it seems a bit non-standard to me but
we have some special requirements, like leaving the original body around;
I could simplify the examples but I might as well show you known-working
code :P  We currently do:

use File::Temp qw(tempfile);
( $txn-{_body_file}, my $filename ) = tempfile( DIR = $self-temp_dir() );
$txn-body_fh-print(\n);
$mime_entity-print_body( $txn-body_fh );
$txn-{_body_size} = (stat($txn-{_body_file}))[7];
$txn-{_body_start} = 0;

An older method that we used to use (I can't remember whether we switched
to the above because it's more efficient, or because of some of the other
weird things we're doing -- at least the above doesn't require
stringify_body() which is probably slightly undesirable):

$txn-body_resetpos;
$txn-{_body_file}-truncate($txn-{_body_start});
$txn-{_body_size} = $txn-{_body_start};
$txn-body_write( $mime_entity-stringify_body() );

Hope this helps.

-Jared

 On 05/20/2011 04:19 AM, Matt Sergeant wrote:
 What do you mean by signed?
 Signing with a gnugp key.

 Actually by signing the original email I get a new MIME::Entity which
 then I need to pass on the queue to get delivered to the real smtp server.
 In other words, the qpsmtpd proxy signs the email and delivers it to the
 real smtp server.
 --
 Thanks for any hint.
 Mike






Re: smtp proxy to external smtp server

2011-05-20 Thread Mike Korizek
On 05/20/2011 02:56 PM, Jared Johnson wrote:
 We do the sort of signing that is a huge doozy, and Matt is right, it's a
 doozy :)  There are a couple of ways we've accomplished re-writing the
 body from a MIME::Entity.  Honestly it seems a bit non-standard to me
Why do you think this is non-standard? From a conceptual perspective or
just from a tooling view?
If conceptually, which other approach would you recommend?

 use File::Temp qw(tempfile);
 ( $txn-{_body_file}, my $filename ) = tempfile( DIR = $self-temp_dir() );
 $txn-body_fh-print(\n);
 $mime_entity-print_body( $txn-body_fh );
 $txn-{_body_size} = (stat($txn-{_body_file}))[7];
 $txn-{_body_start} = 0;
I did some preliminary tests and it works.
That also means there is no API or any other way to put an email into
the queue, isn't it?
Well, can I use this approach in a productive environment or could there
be any side effects?

Thanks for your support on this.
Mike


Re: smtp proxy to external smtp server

2011-05-20 Thread Jared Johnson
 On 05/20/2011 02:56 PM, Jared Johnson wrote:
 We do the sort of signing that is a huge doozy, and Matt is right, it's
 a
 doozy :)  There are a couple of ways we've accomplished re-writing the
 body from a MIME::Entity.  Honestly it seems a bit non-standard to me
 Why do you think this is non-standard? From a conceptual perspective or
 just from a tooling view?
 If conceptually, which other approach would you recommend?

just non-standard in that I don't use public API's, so e.g. if they
decided to store the body file in $txn-notes('body_file') instead of
$txn-{_body_file}, for instance, you'd be SOL.  Other than that, though,
we haven't had any problems with our method :)

I'm not sure if it can be done with a public API, but if you want to look
for a method, i'd check out the POD for Qpsmtpd::Transaction, for the
various body* methods.

 I did some preliminary tests and it works.
 That also means there is no API or any other way to put an email into
 the queue, isn't it?

well, the standard way to put a message into the queue is to have the
message in a state you want it in before the queue hook gets ahold of it,
and then let the queueing plugin do its work... I think smtp-forward is an
example of a queueing plugin?

 Well, can I use this approach in a productive environment or could there
 be any side effects?

YMMV, but we've been using that method in production a while with no side
effects that I know of :)

-Jared



Re: smtp proxy to external smtp server

2011-05-19 Thread Mike Brack
On Tue, May 17, 2011 at 9:03 PM, Matt Sergeant m...@sergeant.org wrote:
 Aleksandar Lazic wrote:

 Just for my curiosity, why don't you use

 qpsmtpd::smtp-forward =Any MTA Setup (postfix,courier,qmail, ...)?

 It's not sender dependent, and doesn't pass on AUTH. (but would be easily
 hackable to do that).
I am also a programmer, I know Java and C but I am sure I can manage perl :-)
The qpsmtpd framework is really cool - thanks a lot!
Cheers,
Mike


Re: smtp proxy to external smtp server

2011-05-19 Thread Mike Korizek
On 05/17/2011 04:24 PM, Matt Sergeant wrote:
 It can be done, but you'll need to customise the smtp-forward plugin
 yourself to do it.
I checked the transaction object, I could not find a handle to the message.
How can I achieve the following:
An email shall be signed and then put back to the queue.
Before signing the email I parse it with a MIME::Parser, but how can I
put the new email back to the queue?
Thanks for any hint.
Mike



Re: smtp proxy to external smtp server

2011-05-19 Thread Matt Sergeant

What do you mean by signed?

Do you mean like adding a banner to the text parts of the email? If so, 
that's a really hard problem (I mean it's doable in simple situations, 
but breaks very very easily).


Mike Korizek wrote:

On 05/17/2011 04:24 PM, Matt Sergeant wrote:
   

It can be done, but you'll need to customise the smtp-forward plugin
yourself to do it.
 

I checked the transaction object, I could not find a handle to the message.
How can I achieve the following:
An email shall be signed and then put back to the queue.
Before signing the email I parse it with a MIME::Parser, but how can I
put the new email back to the queue?
Thanks for any hint.
Mike

   


Re: smtp proxy to external smtp server

2011-05-19 Thread Mike Korizek
On 05/20/2011 04:19 AM, Matt Sergeant wrote:
 What do you mean by signed?
Signing with a gnugp key.

Actually by signing the original email I get a new MIME::Entity which
then I need to pass on the queue to get delivered to the real smtp server.
In other words, the qpsmtpd proxy signs the email and delivers it to the
real smtp server.
--
Thanks for any hint.
Mike



Re: smtp proxy to external smtp server

2011-05-17 Thread Aleksandar Lazic

Hi Mike,

On Die 17.05.2011 10:34, Mike Brack wrote:

Hi all

Can I achieve the following scenariowith qpsmtpd?

Acting as smtp proxy connecting to an external target smtp server which
is sender dependent.
The target smtp server requires smtp auth, so the proxy should pass on
the credentials to the target smtp server.


Just for my curiosity, why don't you use

qpsmtpd::smtp-forward =Any MTA Setup (postfix,courier,qmail, ...)?

Cheers
Aleks


Re: smtp proxy to external smtp server

2011-05-17 Thread Matt Sergeant

Aleksandar Lazic wrote:

Just for my curiosity, why don't you use

qpsmtpd::smtp-forward =Any MTA Setup (postfix,courier,qmail, ...)? 


It's not sender dependent, and doesn't pass on AUTH. (but would be 
easily hackable to do that).


Re: smtp proxy to external smtp server

2011-05-17 Thread Mike Brack
On Tue, May 17, 2011 at 9:03 PM, Matt Sergeant m...@sergeant.org wrote:
 Aleksandar Lazic wrote:

 Just for my curiosity, why don't you use

 qpsmtpd::smtp-forward =Any MTA Setup (postfix,courier,qmail, ...)?

 It's not sender dependent, and doesn't pass on AUTH. (but would be easily
 hackable to do that).

I did a quick prototype and it works - thanks!
I just stumbled on the plugin auth/auth-smtpd - what is this plugin
for? Is just does a auth check

--
Cheers,
Mike


Re: smtp proxy to external smtp server

2011-05-17 Thread Jason Mills
I wrote a similar plugin a while ago to facilitate my testing
environment at home.
Not sure if it works with the current code base but at least can act as
skeleton.

Code: https://gist.github.com/977645
Thread: http://www.mail-archive.com/qpsmtpd@perl.org/msg09252.html

On 05/17/2011 03:40 PM, Mike Brack wrote:
 On Tue, May 17, 2011 at 9:03 PM, Matt Sergeant m...@sergeant.org wrote:
 Aleksandar Lazic wrote:
 Just for my curiosity, why don't you use

 qpsmtpd::smtp-forward =Any MTA Setup (postfix,courier,qmail, ...)?
 It's not sender dependent, and doesn't pass on AUTH. (but would be easily
 hackable to do that).

 I did a quick prototype and it works - thanks!
 I just stumbled on the plugin auth/auth-smtpd - what is this plugin
 for? Is just does a auth check

 --
 Cheers,
 Mike