Drupal + Postfix Integration Under Ubuntu 8.04 (Hardy) - Page 6

Want to support HowtoForge? Become a subscriber!
 
Submitted by asaavedra (Contact Author) (Forums) on Tue, 2008-10-07 15:52. ::

Deliver Incoming Mails Through the Dovecot LDA

To make Postfix use Dovecot you need to append one line to /etc/postfix/master.cf:

vim /etc/postfix/master.cf

dovecot   unix  -       n       n       -       -       pipe
  flags=DRhu user=vmail:vmail argv=/usr/lib/dovecot/deliver -d ${recipient}

Reload Postfix:

/etc/init.d/postfix reload

Now make Postfix deliver mails through this service:

postconf -e virtual_transport=dovecot
postconf -e dovecot_destination_recipient_limit=1

 

Configure Dovecot

Dovecot supports PO3, POP3S, IMAP and IMAPS. To enable all these services modify /etc/dovecot/dovecot.conf to match the following settings:

vim /etc/dovecot/dovecot.conf

protocols = imap imaps pop3 pop3s
mail_location = maildir:/home/vmail/%d/%n/Maildir
auth default {
  mechanisms = plain login
  passdb sql {
    args = /etc/dovecot/dovecot-sql.conf
  }
  userdb static {
    args = uid=5000 gid=5000 home=/home/vmail/%d/%n allow_all_users=yes
  }
  socket listen {
    master {
      path = /var/run/dovecot/auth-master
      mode = 0600
      user = vmail
    }
    client {
      path = /var/spool/postfix/private/auth
      mode = 0600
      user = postfix
      group = postfix
    }
  }
}
protocol lda {
  log_path = /home/vmail/dovecot-deliver.log
  global_script_path = /home/vmail/globalsieverc
  postmaster_address = postmaster@example.com
  auth_socket_path = /var/run/dovecot/auth-master
  mail_plugins = cmusieve
}

Edit /etc/dovecot/dovecot-sql.conf and make sure the following directives are set:

vim /etc/dovecot/dovecot-sql.conf

driver = mysql
connect = host=127.0.0.1 dbname=drupal_example_com user=drupal_example_com password=opensesame
default_pass_scheme = PLAIN-MD5
password_query = SELECT mail AS user, pass AS password FROM users WHERE mail='%u';

Then you must restart Dovecot:

/etc/init.d/dovecot restart

That’s it! Now Drupal and Postfix share the same authentication repository.

 

References

  1. Falko Timme, © 2008, Virtual Users And Domains With Postfix, Courier, MySQL And SquirrelMail (Ubuntu 8.04 LTS), http://www.howtoforge.com/virtual-users-domains-postfix-courier-mysql-squirrelmail-ubuntu8.04
  2. Christoph Haas, © 2007, Howto: ISP-style Email Server with Debian-Etch and Postfix, http://workaround.org/articles/ispmail-etch/
  3. Matt Butcher, Learning Drupal 6 Module Development, ISBN 190-4811-80-9, © 2008 Packt Publishing
  4. Thomas Barregren, Mailserver Drupal Module, http://drupal.org/project/mailserver
  5. Alex Saavedra, © 2008, Mailfix Drupal Module, http://drupal.org/project/mailfix

Please do not use the comment function to ask for help! If you need help, please use our forum.
Comments will be published after administrator approval.
Submitted by plen (not registered) on Sat, 2011-01-29 08:57.
The mail_plugins line in the dovecot.conf should be set to just "sieve" not "cmusieve"
Submitted by Paul H (not registered) on Tue, 2008-10-28 19:25.

It appears that dovecot expects a returned field called 'password' whilst the mysql and drupal returns a field called 'pass' which means that authentications via pop3 and imap don't work.

Any thoughts?

Paul

Submitted by Nik Sulaiman (not registered) on Tue, 2008-11-18 04:11.

in /etc/dovecot/dovecot-sql.conf

add the underlined text:

password_query = SELECT mail AS user, pass AS password FROM users WHERE mail='%u';

I was having the problem too, thanks for the post.

Managed to authenticate via imap successfully. Hope it helps.

Submitted by asaavedra (registered user) on Fri, 2009-03-06 22:29.

Nik Sulaiman,

 Thank you for your fix. It has been updated in the tutorial.

 Alex Saavedra