Drupal + Postfix Integration

Discussion in 'HOWTO-Related Questions' started by handheld, Jan 9, 2010.

  1. handheld

    handheld New Member

    Hello,
    I got halfway through Drupal + Postfix Integration and thought it may not be for me because it started instructing me on how to set up e-mail accounts for Drupal users. Anyway, what I'm trying to do is enable the e-mail for Drupal registrations and reseting passwords, but my test user is still not getting a password reset e-mail. I'm going through the Postfix Debugging Howto, now, but if anyone has any suggestions, please help.
    Thanks
     
  2. falko

    falko Super Moderator Howtoforge Staff

    Are there any errors in your mail log?
     
  3. handheld

    handheld New Member

    Let's see. I think I was looking in the wrong place for errors the other night, but yeah, I have some errors; and I don't see how to fix them because it says
    Code:
    postfix/trivial-rewrite[3064]: warning: do not list domain [my.domain.url] in BOTH mydestination and virtual_mailbox_domains
    but the latter doesn't list the domain like the former. The latter says,
    Code:
    virtual_mailbox_domains = proxy:mysql:/etc/postfix/drupal-domains.cf
    and drupal-domains.cf says, per the instructions:
    Code:
    user = [username]
    password = [password]
    dbname = [dbname]
    query = SELECT domain_name AS domain FROM mailfix_domains
      WHERE domain_name = '%s'
    hosts = 127.0.0.1
    mydestination is set to
    Code:
    mydestination = [my.domain.url], localhost, localhost.[mylocal.domain]
    More errors:
    Code:
    postfix/trivial-rewrite[3079]: warning: do not list domain [my.domain.url] in BOTH mydestination and virtual_mailbox_domains
    postfix/master[2995]: warning: process /usr/lib/postfix/smtp pid 3204 killed by signal 15
    postfix/qmgr[3213]: warning: connect to transport smtp: Connection refused
    postfix/qmgr[2596]: warning: connect to transport smtp: Connection refused
    Here's my master.cf:
    Code:
    2525      inet  n       -       n       -       -       smtpd
    #listens to port 2525 since ISP blocks 25
    pickup    fifo  n       -       -       60      1       pickup
     25 cleanup   unix  n       -       -       -       0       cleanup
     26 qmgr      fifo  n       -       n       300     1       qmgr
     27 #qmgr     fifo  n       -       -       300     1       oqmgr
     28 tlsmgr    unix  -       -       -       1000?   1       tlsmgr
     29 rewrite   unix  -       -       -       -       -       trivial-rewrite
     30 bounce    unix  -       -       -       -       0       bounce
     31 defer     unix  -       -       -       -       0       bounce
     32 trace     unix  -       -       -       -       0       bounce
     33 verify    unix  -       -       -       -       1       verify
     34 flush     unix  n       -       -       1000?   0       flush
     35 proxymap  unix  -       -       n       -       -       proxymap
     36 proxywrite unix -       -       n       -       1       proxymap
     37 #smtp      unix  -       -       -       -       -       smtp
     38 2525      unix  -       -       n       -       -       smtp
     39 # When relaying mail as backup MX, disable fallback_relay to avoid MX loops
     40 relay     unix  -       -       -       -       -       smtp
     41         -o smtp_fallback_relay=
     42 #       -o smtp_helo_timeout=5 -o smtp_connect_timeout=5
     43 showq     unix  n       -       -       -       -       showq
     44 error     unix  -       -       -       -       -       error
     45 retry     unix  -       -       -       -       -       error
     46 discard   unix  -       -       -       -       -       discard
     47 local     unix  -       n       n       -       -       local
     48 virtual   unix  -       n       n       -       -       virtual
     49 lmtp      unix  -       -       -       -       -       lmtp
     50 anvil     unix  -       -       -       -       1       anvil
    scache    unix  -       -       -       -       1       scache
    maildrop  unix  -       n       n       -       -       pipe
     66   flags=DRhu user=vmail argv=/usr/bin/maildrop -d ${recipient}
    uucp      unix  -       n       n       -       -       pipe
     71   flags=Fqhu user=uucp argv=uux -r -n -z -a$sender - $nexthop!rmail ($recipient)
    ifmail    unix  -       n       n       -       -       pipe
     76   flags=F user=ftn argv=/usr/lib/ifmail/ifmail -r $nexthop ($recipient)
     77 bsmtp     unix  -       n       n       -       -       pipe
     78   flags=Fq. user=bsmtp argv=/usr/lib/bsmtp/bsmtp -t$nexthop -f$sender $recipient
     79 scalemail-backend unix  -       n       n       -       2       pipe
     80   flags=R user=scalemail argv=/usr/lib/scalemail/bin/scalemail-store ${nexthop} ${user} ${extension}
     81 mailman   unix  -       n       n       -       -       pipe
     82   flags=FR user=list argv=/usr/lib/mailman/bin/postfix-to-mailman.py
     83   ${nexthop} ${user}
     84 dovecot   unix  -       n       n       -       -       pipe
     85   flags=DRhu user=vmail:vmail argv=/usr/lib/dovecot/deliver -d ${recipient}
    The line numbers are just apart of my .vimrc. Here's my main.cf:
    Code:
    smtpd_banner = $myhostname ESMTP $mail_name 
     10 biff = no
     11 
     12 # appending .domain is the MUA's job.
     13 append_dot_mydomain = no
     14 
     15 # Uncomment the next line to generate "delayed mail" warnings
     16 #delay_warning_time = 4h
     17 
     18 readme_directory = /usr/share/doc/postfix
     19 
     20 # TLS parameters
     21 smtpd_tls_cert_file = /etc/postfix/smtpd.cert
     22 smtpd_tls_key_file = /etc/postfix/smtpd.key
     23 smtpd_use_tls = yes
     24 smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
     25 smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
     26 
     27 # See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
     28 # information on enabling SSL in the smtp client.
     29 
     30 myhostname = [my.domain.url]
     31 alias_maps = hash:/etc/aliases
     32 alias_database = hash:/etc/aliases
     33 myorigin = /etc/mailname
     34 mydestination = [my.domain.url], localhost, localhost.[mylocal.domain]
     35 relayhost =
     36 mynetworks = 127.0.0.0/8
     37 mailbox_command = procmail -a "$EXTENSION"
     38 mailbox_size_limit = 0
     39 recipient_delimiter = +
     40 inet_interfaces = all
     41 html_directory = /usr/share/doc/postfix/html
     42 virtual_alias_domains =
     43 virtual_alias_maps = proxy:mysql:/etc/postfix/drupal-forward.cf
     44 virtual_mailbox_domains = proxy:mysql:/etc/postfix/drupal-domains.cf
     45 virtual_mailbox_maps = proxy:mysql:/etc/postfix/drupal-mailboxes.cf
     46 virtual_mailbox_base = /home/vmail
     47 virtual_uid_maps = static:5000
     48 virtual_gid_maps = static:5000
     49 smtpd_sasl_auth_enable = yes
     50 broken_sasl_auth_clients = yes
    51 smtpd_sasl_authenticated_header = yes
     52 smtpd_sasl_path = private/auth
     53 smtpd_sasl_type = dovecot
     54 smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination
     55 virtual_create_maildirsize = yes
     56 virtual_mailbox_extended = yes
     57 virtual_mailbox_limit_maps = proxy:mysql:/etc/postfix/drupal-quota.cf
     58 virtual_mailbox_limit_override = yes
     59 virtual_maildir_limit_message = "The user you are trying to reach is over quota."
     60 virtual_overquota_bounce = yes
     61 recipient_bcc_maps = proxy:mysql:/etc/postfix/drupal-recipient-bcc.cf
     62 sender_bcc_maps = proxy:mysql:/etc/postfix/drupal-sender-bcc.cf
     63 proxy_read_maps = $local_recipient_maps $mydestination $virtual_alias_maps $virtual_alias_domains $virtual_mailbox_maps $virtual_mailbox_domains            $relay_recipient_maps $relay_domains $canonical_maps $sender_canonical_maps $recipient_canonical_maps $relocated_maps $transport_maps $mynetworks           $virtual_mailbox_limit_maps $recipient_bcc_maps $sender_bcc_maps
     64 virtual_transport = dovecot
     65 dovecot_destination_recipient_limit = 1
     
  4. falko

    falko Super Moderator Howtoforge Staff

    This means you have my.domain.url in mydestination and also in the MySQL database. You can have it in only one location, not both. If you want to use that domain for virtual users, please remove it from mydestination and restart Postfix.
     
  5. asaavedra

    asaavedra New Member

    Mailfix module

    You're probably right. This module is intended for centralized authentication between Drupal and Postfix. If you just need to send Drupal alerts, it should work out of the box. You may want to monitor the mail log:
    Code:
    sudo tail -f /var/log/mail/mail.log
    If the mail is actually being sent, check the anti-spam folder. If the mail is not being sent, check your Drupal site configuration. The Drupal log will help.
     
  6. handheld

    handheld New Member

    Okay, this is still a little over my head, but I want to hang in there. I could definitely remove the domain name from the main.cf even though I don't understand virtual users. My guess would be anyone who doesn't have an actual user account on my server, i.e. those Drupal users requesting a password or registering.

    On the other hand, I monitored the mail.log while requesting a new password, and it showed something interesting:
    I know I left the domain name in there this time because, what, I don't want visitors?? It's just a blank message board though.

    Alright, what I did was change the
    to
    and restarted the postfix daemon that's in init.d, but it didn't make a difference until I put case-sensitive letters in the captcha. Never can tell with those captchas unless they're explicit. This one, Mollum, was telling me an e-mail was sent no matter what I put in there. The difference was it left out the line about refused smtp connection, but four minutes later, it spouted all those original four lines out again. Then, I took out the domain name from main.cf and restarted the postfix daemon again, but same errors; so I'm reverting back both files. I also rebooted after making the changes, but that didn't work.

    PS Should the myhostname be my server's hostname or the web domain name?
     
    Last edited: Jan 11, 2010
  7. asaavedra

    asaavedra New Member

    Postfix configuration

    Handheld,

    It seems to be a Postfix issue. I don't think you need Mailfix domain to accomplish what you want (send Drupal alerts), so you probably don't need virtual hosts at all. It seems like you want your Drupal server to send out mail messages directly. Thus your Postfix configuration should have mydestination directive include localhost. To verify this:
    Code:
    sudo postconf | grep mydestination
    Check if localhost is included in this directive (my guess is it isn't). In case it's not, just reconfigure:
    Code:
    sudo postconf -e "mydestination = you.host.here, localhost, localhost.localdomain"
    Then your messages should be sent as expected. HTH
     
  8. handheld

    handheld New Member

    hmm, mydestination already says localhost :-/
    I could uninstall Mailfix. I uncommented the smtp unix line, and the trial timed out; so I found out to set up a relayhost; but my ISP doesn't allow home servers; so I guess I better switch ISPs.
     
  9. asaavedra

    asaavedra New Member

    Drupal SMTP modules

    You may also want to try SMTP Drupal modules. PHPMailer is an excellent module for remote SMTP authentication, you may use a Gmail account, for instance.
     
  10. handheld

    handheld New Member

    thanks a lot :) It threw an error
    which I don't understand:
    but it sent the password reset e-mail!! :) thanks again
     

Share This Page