Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By Mapi99 on
Hello all,
I have a linode server where i have complete root acces, i have a postfix mail server running.
But what i really want to do is somehow integrate postfix and drupal, i know there is a module for 6.x but it offers alot of features i dont need and i wish to use 7.x
Is it possible to let Postfix load or grab existing passwords and usernames from the drupal database and use them as email adresses?
Thanks,
mapi
Comments
Postfix + MySQL
This is possible.
Checkout:
http://www.postfix.org/MYSQL_README.html
You may want to add a field or two to users or even create a module if the users aren't all in the same domain.
Hello Scott, thanks for the
Hello Scott, thanks for the reply
The page you linked doesn't specifically say about hooking up postfix to an existing db, it just says you can connect it to a mysql db.
So basically the way to do this is write a module that will generate the required rows and tables in the database, and POINT postfix to those instead of its own db, correct?
Thanks alot guys, hope to get some more insight,
Mapi
Yes
It looks to me that you can specify the query to use in the Postfix configuration. If so you just need to put together a query which will get the user ids and email address from Drupal's table.
It may be wise to get Postfix working with MySQL first then get fancy.
Big green boats
Mapi, I'm in the same lime-green boat. I'm running aegir. I couldn't get the Mailfix module to work at all, though it might be a good starting point. An email module that depends on the hosting module might be the way forward - it could alter the site node edit-forms and also hook into the quotas part of aegir.
I'm not too keen on the idea of auto-creating email addresses for every drupal user, or the idea of letting people who's websites i'm hosting do that either. Quotas and roles would be the way forward. It could even link up with the uc_hosting module so people can but email addresses.
I've only done a few hook_form_alters and a fair bit of theming - I've never written a proper module. But i'm up for collaborating.
Linode's disk image restore FTW!
If I do try this, I'll be clicking that button a lot.
One thing I really have no idea about is the 'Drupal Way' of talking to the database. Can somebody point me in the right direction?
Drupal and mail integration.
you don't need mailfix.
Mail forwarding, is quite straightforward. All you need is root access on your server, a running postfix some mysql query magic.
Asume your site is called "drupal.org", your database drupal, and there is a mysql user "mail" with select privileges on "users", and password "mail".
create a file named "drupal_forward.cf". The content of this file is:
You'll need to edit this file to make it fit your install.
Your postfix main.cf you need to edit so that it containst the following:
And there is a clever trick that allows me to send emails to all users that have a certain role. I have a second query configured like this:
drupal_roles.cf
For this to work the mail users now also needs select privileges on users_roles, and role.
My main.cf now needs to contain:
Postfix will check each map listed in the virtual_alias_maps variable. If you have a hash file (to have some manual aliases too) you can also list it there:
On my site users actually have the option to have mail delivered to a local imap mailbox, but that is a bit more complicated. I did however solve that purely using postfix's mysql features, and dovecot for imap/pop. I did not need any special modules.
Thanks, this was really
Thanks, this was really helpful.
I have now managed to get postfix to lookup teacher1@example.org.au and return the email adress (Teacher1TEST@example.org.au) attached to that user in Drupal to postfix. But then Postfix gives me an error saying that the email address is not found. Does not matter if I set the email adress to teacher1@example.org.au in drupal, same error. Dont I need some kind of maildrop setting?
Thanks!
Working!
Got it to work with the following:
Postfix + Joyent Server
This just FYI, so that nobody waste their time if they are working on the Joyent's Smart Machine server,
Joyent's Postfix mail server does not have a Mysql support.