Koozali.org: home of the SME Server

adding a new plugin to qpsmtpd

Offline jibe

  • ****
  • 128
  • +0/-0
adding a new plugin to qpsmtpd
« on: January 05, 2012, 05:00:38 PM »
Hi,

I'm trying to add a new plugin to qpsmtpd, but it seems not working...

Here is what I did :

- Put my plugin named "my_plugin" in /usr/share/qpsmtpd/plugins/
- Create a template: /etc/e-smith/templates-custom/var/service/qpsmtpd/config/peers/0/55my_plugin containing "my_plugin"
- Create the same template in .../local/
- signal-event email-update

I can see the added template in /var/service/qpsmtpd/config/peers/0 as well as in .../local :
Code: [Select]
...
check_goodrcptto extn -

rcpt_ok
my_plugin

# pattern_filter disabled

tnef2mime
...

But it has no effect...
what did I miss ?

Another almost similar problem : how can I enable Gavin's denysoft_multi_rcpt plugin ? I tried to do the same way, but it doesn't work. But here, I surely miss some config file for the matching domain and config tests. How to do that ?

Thanks.

Offline mmccarn

  • *
  • 2,656
  • +10/-0
Re: adding a new plugin to qpsmtpd
« Reply #1 on: January 06, 2012, 03:45:31 AM »
That all looks right to me.

Have you tried increasing the log level and checking the logs for any messages?

Code: [Select]
config setprop qpsmtpd LogLevel 8
signal-event email-update

Offline jibe

  • ****
  • 128
  • +0/-0
Re: adding a new plugin to qpsmtpd
« Reply #2 on: January 09, 2012, 04:16:39 PM »
Hi,

The loglevel was already set to 8.

I try with a very simple plugin :
Code: [Select]
sub register {
  my ($self, $qp, %arg) = @_;
  $self->{_match} = $arg{match};
  $self->register_hook("rcpt", "my_plugin");
}

sub my_plugin {
  my ($self, $transaction, $rcpt) = @_;
  $self->qp->log(LOGINFO, "my_plugin is working !");
    return DECLINED;
}

In the log, I have :
Code: [Select]
2012-01-09 15:58:43.593785500 4156 rcpt_ok hooking rcpt
2012-01-09 15:58:43.595949500 4156 my_plugin hooking rcpt
2012-01-09 15:58:43.597659500 4156 tnef2mime hooking data_post
but not the message supposed to be written in the log. I tried with various loglevels, and also $self->log instead of $self->qp->log, but I never get anything more in the log file...

What is wrong ? What can I try more ?

Offline mmccarn

  • *
  • 2,656
  • +10/-0
Re: adding a new plugin to qpsmtpd
« Reply #3 on: January 10, 2012, 02:06:56 PM »
I found I had to issue sv t qpsmtpd before qpsmtpd would recognize any changes to either the config files or the contents of the plugin.

Doing this got a message in /var/log/qpsmtpd/current:

1) Download your plugin code and save it as /usr/share/qpsmtpd/plugins/my_plugin
2) Change 'LOGINFO' to 'LOGWARN' (just to avoid changing my loglevel)
3) Insert "my_plugin" between "#bcc disabled" and "check_relay" in /var/service/qpsmtpd/config/peers/0
4) restart qpsmtpd using sv t qpsmtpd
5) send myself an email from an outside host

results:
@400000004f0c378e34f27374 4866 my_plugin is working !
@400000004f0c378e35e3f794 4866 check_goodrcptto plugin (rcpt): stripping '-' extensions

Offline jibe

  • ****
  • 128
  • +0/-0
Re: adding a new plugin to qpsmtpd
« Reply #4 on: January 19, 2012, 04:28:48 PM »
Hi,

Sorry to be so late to answer...

Yes, it's working !

I don't understand why it cannot work just with
Code: [Select]
signal-event email updateand works well with
Code: [Select]
sv t qpsmtpd??? Should not this command launched by the email-update event ?