roundcube / roundcubemail

The Roundcube Webmail suite
https://roundcube.net
GNU General Public License v3.0
5.75k stars 1.62k forks source link

Markasjunk: Use different SMTP server/port for learning spam/ham via email #7585

Open medusared opened 3 years ago

medusared commented 3 years ago

When using the markasjunk plugin with the email_learn driver to forward emails to a spam learning system, is it possible to send using a different smtp port number to the default one in the main roundcube config.inc.php? I've looked at the code for plugins/markasjunk/drivers/email_learn.php and can see it uses the rcmail_sendmail class, but is there any way to modify the code to set a custom smtp port number for sending with markasjunk plugin+email_learn? Our spam learning uses a different port number so this would be so useful to us. Thanks for any insight into finding a solution!

alecpl commented 3 years ago

It shouldn't be hard to implement. It could be done as

  1. Add plugin configuration option(s)
  2. Before $SENDMAIL->deliver_message() execute $RCMAIL->smtp_init(true)
  3. Before that set smtp_* options accordingly or even extend smtp_init to pass these as its arguments. There's many smtp options, but we could support these available as arguments of rcube_smtp::connect().
medusared commented 3 years ago

Thanks so much. Here's what I've done:

The above works and sends on the desired port number. Can you see any issues with this? Should it be 'rcube->config->set' or 'rcube->config->merge'? And should the port number be set back to the default after the $SENDMAIL->deliver_message()? Finally I didn't use $RCMAIL->smtp_init(true) - is that necessary? Sorry for my ignorance, any comments are very welcome to improve what I've done.