[FreeBSD 5.2.1] Sendmail is being a b!tch

Discussion in 'Linux & BSD' started by Glaanieboy, Oct 17, 2004.

  1. Glaanieboy

    Glaanieboy Moderator

    Messages:
    2,626
    Location:
    The Netherlands
    This happens every time I try to send an email using the PHP mail() function (from /var/log/maillog):
    Code:
    Oct 17 17:44:01 server1 sm-mta[80036]: i9HFNwfp080034: to=<glaanieboy@msn.com>, delay=00:20:02, xdelay=00:20:02, mailer=esmtp, pri=30893, relay=mx4.hotmail.com. [65.54.190.230], dsn=4.0.0, stat=Deferred: Operation timed out with mx4.hotmail.com.
    Same thing happens with gmail.com, wanadoo.nl addresses etc etc. php.ini is configured properly, sendmail seems to work ok, so I guess it's some setting in the OS, but where? Can anyone help me? :mad: I got it to work before on a FreeBSD 4.9 machine, so I am kinda frustrated now, since I copied/pasted the PHP code from a script I worked with before.
     
  2. Reg

    Reg eXperienced!

    Messages:
    639
    Location:
    Arlington, TX
    I've seen similar problems before with Hotmail and my own servers. It appears as though Hotmail will only accept mail from trusted servers. If you sendmail has the ability to determine this, they will block it if it's not trusted.
     
  3. Glaanieboy

    Glaanieboy Moderator

    Messages:
    2,626
    Location:
    The Netherlands
    Weird. I just sent a mail to my own wanadoo.nl (ISP) email address and it worked. Looks like gmail and hotmail/msn blocks my email. But why? It worked before (I know for sure, because I did a demonstration for a PHP product I made for a client about 3 weeks ago and there I used my gmail.com address as a test), why not now?
     
  4. Glaanieboy

    Glaanieboy Moderator

    Messages:
    2,626
    Location:
    The Netherlands
    I remember now! I used a qmail wrapper for sendmail, which I configured to send all emails to smtp.wanadoo.nl (my ISP's SMTP server). Does anyone know how I can configure sendmail to do the same? Because at the moment it seems to automagically detect the smtp.wanadoo.nl server, but still sending it as it was from server1.thuisnet.lan (localhost), which is an invalid domain.
     
  5. Glaanieboy

    Glaanieboy Moderator

    Messages:
    2,626
    Location:
    The Netherlands
    Finally! I found the answer on http://lists.freebsd.org/pipermail/freebsd-questions/2003-July/014468.html:
    :D It worked. I immediately got 7 emails on my MSN account and 6 on my gmail account, all failed mails :D
     
  6. X-Istence

    X-Istence * Political User

    Messages:
    6,498
    Location:
    USA
    juck, sendmail.
     
  7. Glaanieboy

    Glaanieboy Moderator

    Messages:
    2,626
    Location:
    The Netherlands
    Any reasons why you find it 'juck'? :rolleyes:
     
  8. X-Istence

    X-Istence * Political User

    Messages:
    6,498
    Location:
    USA
    Yep:

    runs as root standard
    Required to run as root or it won't work
    Always full of security holes
    Does not seperate queue handling from incoming message handling. Can be done, but then mail gets slowed down till the queue handler sees the new mail.

    It is a pain to configure properly, and secure. And did i mention it runs as root standard?
     
  9. LordOfLA

    LordOfLA Godlike!

    Messages:
    7,027
    Location:
    Maidenhead, Berkshire, UK
    you would do better to use one of the following 2 MTA's: qmail or postfix.

    I swear by postfix, X-istance swears by qmail :)

    and walk slowly away from sendmail: big bloated and insecure
     
  10. Glaanieboy

    Glaanieboy Moderator

    Messages:
    2,626
    Location:
    The Netherlands
    :eek: *installs qmail instead* Thanks guys!
     
  11. Glaanieboy

    Glaanieboy Moderator

    Messages:
    2,626
    Location:
    The Netherlands
    O...K, I installed qmail, changed sendmail_path to sendmail_path = /var/qmail/bin/sendmail -t -i, but it doesn't work. I guess I have to edit some config files, but I don't know how the file format is, so I guess I would have to look it up at some website, but I am tired atm so I'll see that tomorrow. Unless someone wants to help me *wink*wink* ;) (I only need to know how I redirect the qmail sendmail to an external SMTP)
     
  12. X-Istence

    X-Istence * Political User

    Messages:
    6,498
    Location:
    USA
    edit /var/qmail/control/smtproutes and add an entry:

    :smtp.wanadoo.nl

    Yes, include the coloon, or it will not work.

    now svc -dx /var/qmail/services/*

    within 5 seconds it will start working. Do note, that if you used some guide that uses inetd, youll have to either. If you used deamontools then just do what i said.

    reboot
    or somehow restart qmail.
     
  13. Glaanieboy

    Glaanieboy Moderator

    Messages:
    2,626
    Location:
    The Netherlands
    Uhm, ok. I didn't use daemontools, I installed it now, but I think I buggered up something, because I don't have a /var/qmail/services dir. I grabbed your guide from bsdguides.org, but it is packed with loads of stuff I don't need. I only need a redirect to an external SMTP, that's all.
     
  14. X-Istence

    X-Istence * Political User

    Messages:
    6,498
    Location:
    USA
    you installed it all, but did not create any way to run it or anything.

    run the following commands:

    Code:
    cd /usr/ports/mail/qmail
    killall -9 sendmail
    make fetch all install force-enable-qmail WITH_QMAILQUEUE_PATCH=yes WITH_BIG_TODO_PATCH=yes \
    WITH_BIG_CONCURRENCY_PATCH=yes WITH_OUTGOINGIP_PATCH=yes
    echo "no_sendmail=\"YES\"" >> /etc/make.conf
    cd /usr/ports/sysutils/ucspi-tcp
    make install clean
    cd /usr/ports/sysutils/daemontools
    make install clean
    echo 'svscan_enable="YES"' >> /etc/rc.conf
    cd /usr/ports/mail/qmail-conf/
    make install clean
    rm /usr/local/etc/rc.d/qmail.sh
    hostname > /var/qmail/control/me
    hostname | sed "s/`hostname -s`.//g" > /var/qmail/control/defaultdomain
    hostname | sed "s/`hostname -s`.//g" > /var/qmail/control/plusdomain
    /var/qmail/bin/qmail-smtpd-conf qmaild qmaill /var/qmail/service/smtpd
    cd /var/qmail/service/smtpd/
    echo "200" > env/CONCURRENCY
    echo '127.0.0.1:allow,RELAYCLIENT=""' > tcp
    echo ":allow" >> tcp
    make
    echo '#\!/bin/sh' > /var/qmail/rc
    echo 'exec env - PATH="/var/qmail/bin:$PATH" \' >> /var/qmail/rc
    echo 'qmail-start ./Maildir/ /usr/local/bin/multilog t /var/log/qmail qmaill' >> /var/qmail/rc
    chmod 755 /var/qmail/rc
    /var/qmail/bin/qmail-delivery-conf qmaill /var/qmail/service/qmail
    mkdir /var/log/qmail
    chmod 750 /var/log/qmail
    chown qmaill /var/log/qmail
    mkdir /var/service
    ln -s /var/qmail/service/smtpd /var/service/smtpd
    ln -s /var/qmail/service/qmail /var/service/qmail
    echo ":smtp.wanadoo.nl" > /var/qmail/control/smtproutes
    /usr/local/etc/rc.d/svscan.sh start
    
    That should do it. Any local deliveries will be stuck in mail queue for 7 days as you don't have any local accounts, unless you:

    Code:
    cd /root
    /var/qmail/bin/maildirmake Maildir
    
    Which is suggested so that crontab can send its stuff there when needed.

    X-Istence
     
  15. Glaanieboy

    Glaanieboy Moderator

    Messages:
    2,626
    Location:
    The Netherlands
    Yay! Thank you! Works like a charm :D
     
  16. Geffy

    Geffy Moderator Folding Team

    Messages:
    7,805
    Location:
    United Kingdom
    btw for php its best to set the sendmail path to /var/qmail/bin/qmail-inject
     
  17. X-Istence

    X-Istence * Political User

    Messages:
    6,498
    Location:
    USA
    Does that take the same paramaters?
     
  18. LordOfLA

    LordOfLA Godlike!

    Messages:
    7,027
    Location:
    Maidenhead, Berkshire, UK
    qmails sendmail wrapper just takes input from php and converts it to qmail-inject so there is no reason to change php at all when it detects the sendmail wrapper.
     
  19. Geffy

    Geffy Moderator Folding Team

    Messages:
    7,805
    Location:
    United Kingdom
    one less level of crap though :p
     
  20. X-Istence

    X-Istence * Political User

    Messages:
    6,498
    Location:
    USA
    Doesnt matter all that much. And PHP likes to send sendmail flags which qmail-injecct might not understand.