Drupal + Postfix Integration Under Ubuntu 8.04 (Hardy) - Page 5
Postfix ConfigurationWe create a user and group called vmail with uid and gid set as 5000 with the home directory /home/vmail. This is where all mail boxes will be stored. groupadd -g 5000 vmail Now is the time to configure Postfix directives. The drupal-domains.cf tells Postfix which are the domains managed by your Drupal installation: vim /etc/postfix/drupal-domains.cf user = drupal_example_com password = opensesame dbname = drupal_example_com query = SELECT domain_name AS domain FROM mailfix_domains WHERE domain_name = '%s' hosts = 127.0.0.1 Only active Drupal accounts (users.status = 1) will receive emails. You can still configure disabled accounts to forward their mails to another destination by means of mailfix_users.forward field. vim /etc/postfix/drupal-mailboxes.cf user = drupal_example_com
password = opensesame
dbname = drupal_example_com
query = SELECT CONCAT(md.domain_name, '/', LEFT(u.mail, LOCATE('@', u.mail) - 1),'/') AS maildir
FROM mailfix_domains md JOIN (mailfix_users mu JOIN users u
ON mu.uid = u.uid)
ON md.domain_id = mu.domain_id
WHERE u.status = 1 AND u.mail ='%s'
hosts = 127.0.0.1
Forwarded mails apply to both active or disabled Drupal accounts. Some users could simply be on termporary leave or vacations (users.status = 1) while other users may correspond to off-boarding scenarios (disabled accounts, i.e. users.status = 0). Both situations can be handled with automatic mail forwarding. vim /etc/postfix/drupal-forward.cf user = drupal_example_com password = opensesame dbname = drupal_example_com query = SELECT mu.forward FROM mailfix_users mu JOIN users u ON mu.uid = u.uid WHERE u.mail = '%s' AND LENGTH(mu.forward) > 0 hosts = 127.0.0.1 Postfix silent BCC monitoring is split in two parts: incoming and outgoing mails monitoring. vim /etc/postfix/drupal-recipient-bcc.cf user = drupal_example_com password = opensesame dbname = drupal_example_com query = SELECT mu.incoming_bcc FROM mailfix_users mu JOIN users u ON mu.uid = u.uid WHERE u.status = 1 AND u.mail = '%s' AND LENGTH(mu.incoming_bcc) > 0 hosts = 127.0.0.1 vim /etc/postfix/drupal-sender-bcc.cf user = drupal_example_com password = opensesame dbname = drupal_example_com query = SELECT mu.outgoing_bcc FROM mailfix_users mu JOIN users u ON mu.uid = u.uid WHERE u.status = 1 AND u.mail = '%s' AND LENGTH(mu.outgoing_bcc) > 0 hosts = 127.0.0.1 Quota management. vim /etc/postfix/drupal-quota.cf user = drupal_example_com password = opensesame dbname = drupal_example_com query = SELECT mu.quota FROM mailfix_users mu JOIN users u ON mu.uid = u.uid WHERE u.mail = '%s' hosts = 127.0.0.1 Then we must ensure MD5 password encryption is being used. For this we modify /etc/pam.d/smtp mapping to Drupal users table: vim /etc/pam.d/smtp auth required pam_mysql.so user=drupal_example_com passwd=opensesame host=127.0.0.1 db=drupal_example_com table=users usercolumn=mail passwdcolumn=pass crypt=0 account sufficient pam_mysql.so user=drupal_example_com passwd=opensesame host=127.0.0.1 db=drupal_example_com table=users usercolumn=mail passwdcolumn=pass crypt=0 (Parameter crypt=1 seems to be for ENCRYPT function, and crypt=0 seems to be for MD5 function.) Then we need to restart Postfix and Saslauthd: /etc/init.d/postfix restart Then modify /etc/postfix/sasl/smtpd.conf: vim /etc/postfix/sasl/smtpd.conf pwcheck_method: saslauthd mech_list: plain login allow_plaintext: true auxprop_plugin: mysql sql_hostnames: 127.0.0.1 sql_user: drupal_example_com sql_passwd: opensesame sql_database: drupal_example_com sql_select: SELECT pass FROM users WHERE mail = '%u' AND status = 1 Now apply required directives to make Postfix map to all these files: postconf -e 'myhostname = server1.example.com' The smtpd_tls_cert_file and smtpd_tls_key_file directives for SSL client connectivity have been setup. However the corresponding files do not exist yet. The following commands will create them (replace highlighted settings with your own): cd /etc/postfix Country Name (2 letter code) [AU]: BO For security reasons it is adviseable that you change the permissions for smtpd.key: chmod o= /etc/postfix/smtpd.key
|



Recent comments
2 hours 13 min ago
11 hours 41 min ago
12 hours 31 min ago
16 hours 4 min ago
20 hours 28 min ago
20 hours 50 min ago
23 hours 5 sec ago
1 day 9 hours ago
1 day 14 hours ago
1 day 15 hours ago