[RCD] [PATCH] Plugin hook for SMTP authentication

Emmanuel Dreyfus manu at netbsd.org
Thu Jun 4 10:58:10 CEST 2015


Hello

Attached is a patch that adds a plugin hook for SMTP authentication. 
I use it to setup a custom SASL authentication.

I suspect I have already submitted it some time ago and that it
is superseeded by the smtp_auth_callbacks feature that is just 
below. Is there any documentation or example on how to use the
later?

-- 
Emmanuel Dreyfus
manu at netbsd.org
-------------- next part --------------
--- program/lib/Roundcube/rcube_smtp.php.orig
+++ program/lib/Roundcube/rcube_smtp.php
@@ -114,8 +114,20 @@
             $this->conn->setDebug(true, array($this, 'debug_handler'));
             $this->anonymize_log = 0;
         }
 
+        // plugin hook to add SASL mechanisms
+        $result = $rcube->plugins->exec_hook('smtp_add_auth', array(
+            'conn' => $this->conn,
+        ));
+
+        if (is_a($result, 'PEAR_Error')) {
+            $this->response[] = "Authentication setup failed: ".$result->getMessage();
+            $this->error = array('label' => 'smtpconnerror', 'vars' => array('code' => $this->conn->_code));
+            $this->conn = null;
+            return false;
+        }
+
         // register authentication methods
         if (!empty($CONFIG['smtp_auth_callbacks']) && method_exists($this->conn, 'setAuthMethod')) {
             foreach ($CONFIG['smtp_auth_callbacks'] as $callback) {
                 $this->conn->setAuthMethod($callback['name'], $callback['function'],


More information about the dev mailing list