It's better when it's simple

User Tools

Site Tools


SwiftMailer plugin

Compatible with DokuWiki

Angua, Adora Belle

plugin This plugin uses the SwiftMailer class to send DokuWiki mails and supports using a remote SMTP (with optional auth) without relying on PHP's mail() function

Last updated on

This extension has not been updated in over 2 years. It may no longer be maintained or supported and may have compatibility issues.

Tagged with email, smtp, smtpauth

This plugin replaces the way DokuWiki sends emails. Instead of relying on PHP's built-in mail function, it uses the SwiftMailer library. This is especially useful when configuring PHP for sending mails is complicated (Windows) or not possible. SwiftMail is included in the plugin and does not need to be downloaded separately.

Download and Installation

Download and install the plugin using the Plugin Manager using the download link given above. Refer to Plugins on how to install plugins manually.



All config options can be set in the configuration manager under the “Swiftmail Plugin Settings” section (see screenshot). Additionally you need to set up the mailfrom option, which is in the “Notification Settings” section of the configuration manager.

SwiftMail Plugin Settings

When the last option is enabled the whole SMTP session will be printed directly to the screen when sending the mail fails.


The plugin adds a new item to the Admin screen. Using this you can trigger sending a test mail from DokuWiki. If something goes wrong sending this mail, a detailed log is printed.

Known Issues

#1 HTML mails and attachments not supported

This plugin does only support sending plain text emails. HTML mails and attachments are currently not supported (See Issue #7).

The plugin use an old version of Swiftmailer library but here is the nice workaround to get full capabilities with this plugin : HTML mails and attachments !

First, we need to add 2 lines in /inc/Mailer.class.php at line 629 ( method send() ) :

            'body'    => &$this->text,
            # Added vars
            'attach'  => &$this->attach,
            'html'    => &$this->html,
            # End added vars

This give us direct access of attachment array and body in html version.

And 1 line in /inc/Mailer.Class.php at line 79 ( method attachFile() ) :

        $this->attach[] = array(
          'path' => $path,

The path var is redundant with data but i would'nt rebuild the file with file_put_contents function and this version of SwiftMailer seems not support inline file data.

Then, we add some code for HTML body support in /lib/plugins/swiftmail/action.php in line 64 :

            //$message =& new Swift_Message($event->data['subject'], $event->data['body']);
            # We need access to $conf['htmlmail'] parameter
            global $conf;
            $message =& new Swift_Message($event->data['subject']);
            # add text/plain multipart body
  	    $message_text_part = new Swift_Message_Part($event->data['body']);
  	    # add text/html multipart body  		    
            if ($event->data['html'] && $conf['htmlmail']) {			  
		  $message_html_part = new Swift_Message_Part($event->data['html']);

Notice old line with $message = & new Swift_Message(… is commented.
global conf is needed to give access to global configuration parameters array. You can put it at the begining of the function.

And the attachment support in line 123 :

            // Attachment support
            if (count($event->data['attach'])>0){
              foreach ($event->data['attach'] as $attachment){
                $swiftAttachment = new Swift_Message_Attachment(new swift_file($attachment['path']),$attachment['name'],$attachment['mime']);

This work fine for me with support of htmlmail config parameter for notification. I use it too with Bureaucracy plugin.

Hope you find this hack great !

#2 Authentication failed (Gmail)

Gmail denies the access of swiftmail as the security is deemed not secure enough. The workaround is to reduce the security level to allow “less secure” app to access Gmail.

Allowing less secure web to access your account

Added 12/06/2016


plugin/swiftmail.txt · Last modified: 2015-06-12 17:07 by