The Perfect Setup - Debian Etch: smart_host

Discussion in 'Server Operation' started by bidevi, Jul 20, 2007.

  1. bidevi

    bidevi New Member

    On Fedora Core 6 in /etc/mail/sendmail.mc I configured Sendmail's smart_host, so visitors of my site practically use my ISP's smtp server to send me their message filling in a web form. For configuration I used instructions provided by: http://www.go2linux.org/node/35.

    Now I have Postfix, because I've set up Debian Etch following the guide lines of The Perfect Setup instructions.

    Can anyone tell me how to do a smart-host like configuration now, so my visitors can keep on doing the same thing: send me mail using a web form on my site?
     
  2. bidevi

    bidevi New Member

    No reax, so question 2: is there a form mail for Postfix?

    My ISP is 1&1 in Germany and they have strange habits. For example, I cannot get a PHP mail form script working. This is what 1&1 says about it: The only FormMail script you can use on the 1&1 servers is the NMS FormMail.pl. This can be downloaded from http://nms-cgi.sourceforge.net/scripts.shtml. (See: http://faq.1and1.com/scripting_languages_supported/formmail_explained/index.html. As a matter of fact, FormMail.pl works with Sendmail, not Postfix.

    Nevertheless, on Fedora Core 6 I did get form mail working with a perl script that addresses Sendmail. The script was written by Kristina Pfaff-Harris and it can be found here: http://tesol.net/scripts/AutoCGIMail/.

    For the Perfect Etch Setup on my Debian machine I installed Postfix instead of Sendmail. Kristina does not offer her script for Postfix.

    My question: can anyone recommend a good Postfix mail form script?
     
    Last edited: Jul 20, 2007
  3. falko

    falko Super Moderator Howtoforge Staff

    Take a look at the Smart Host section on http://www.fredshack.com/docs/postfix.html

    Postfix is compatible to Sendmail, so I don't know why it shouldn't work with Postfix. Postfix even comes with a binary called sendmail to guarantee Sendmail compatibility.
     
  4. bidevi

    bidevi New Member

    So can I use Postfix just like Sendmail?

    Thank you, Falko, for your response.

    If Postfix works like Sendmail, does that mean that I can change Sendmail to Postfix and everything works fine?

    I've tried that before. On my FC6 machine with Sendmail I've got a perl script with content as displayed below. After configuring smarthost in Postfix on my Debian machine I tried this same perl script after changing every instance of Sendmail in the cgi file to Postfix. I didn't really believe it would work, but if experts tell me Postfix behaves like Sendmail, I assume that scripts written for Sendmail work with Postscript. It didn't.

    Below is a part of the cgi file where I changed every instance of sendmail to postfix (I didn't change it below and I tried the script also in its original form, but nothing worked):

    #!/usr/bin/perl

    # This email script generated by AutoCGIMail v1.2
    # by Kristina Pfaff-Harris (http://www.tesol.net/scripts/)
    #
    # If you're having problems getting this to work, try putting
    # $debugging = 1; on the next line.

    $path_to_sendmail = "/usr/sbin/sendmail";
    $email_field = "01Uw_e-mailadres";
    $use_autoresponse = "Yes";
    $autoresponse_message1 = "Geachte ";
    $autoresponse_message2 = ",

    (et cetera)

    But it's all not that simple. So how do I adapt things in such a way that my perl scripts, working well in Sendmail, keep on working in Postfix?

    (Later this week I'll configure the apps again and try instructions at http://www.fredshack.com/docs/postfix.html)
     
    Last edited: Jul 23, 2007
  5. falko

    falko Super Moderator Howtoforge Staff

    All you have to change is the path to sendmail. You can find out the path by running
    Code:
    which sendmail
     
  6. bidevi

    bidevi New Member

    Another try

    During my experiments to get to know Debian and ISPConfig I always login as root. If something goes really wrong, I just reinstall the OS.

    In Terminal:
    # which sendmail
    /usr/sbin/sendmail

    No luck: that's what is in my cgi script already.

    I'll describe the working situation first.

    SENDMAIL

    Let's assume you own domain happydomain.com. Let's also assume that your ISP's outgoing mail server uses this smtp code: smtp.nicehost.com, and your email address is [email protected].
    Furthermore
    user name: blahusername
    password: blahpassword

    Say you need an smtp server to send email through mail forms on your web page, hosted on your own server at home. If you want to use your ISP's smtp server you can do this with the help of smarthost.

    The following configuration works flawlessly in Fedora Core 6 (FC6) with Sendmail:

    In /etc/mail/sendmail.mc add these lines:

    dnl MASQUERADE_AS('your.domain')dnl
    define(`SMART_HOST',`your.smtp.server')dnl
    FEATURE(`masquerade_envelope')dnl
    FEATURE(genericstable, `hash -o /etc/mail/genericstable')dnl
    GENERICS_DOMAIN_FILE(`/etc/mail/genericsdomain')dnl

    These lines have to be modified to look like:

    dnl MASQUERADE_AS('happydomain.com')dnl
    define(`SMART_HOST',`smtp.nicehost.com')dnl
    FEATURE(`masquerade_envelope')dnl
    FEATURE(genericstable, `hash -o /etc/mail/genericstable')dnl
    GENERICS_DOMAIN_FILE(`/etc/mail/genericsdomain')dnl

    In order to authenticate to the email server of your ISP make sure to have the following line in the file /etc/mail/sendmail.mc:

    FEATURE(`authinfo', `hash /etc/mail/authinfo')

    and create this file:

    /etc/mail/authinfo

    with this inside:

    AuthInfo:your.smtp.server "U:[email protected]" "I:user" "P: passwd" "M:LOGIN PLAIN"

    where you modify this line to look like this:

    AuthInfo:smtp.nicehost.com "U:[email protected]" "I:blahusername" "P:blahpassword" "M:LOGIN PLAIN"

    Now generate the sendmail.cf file using this command:
    make -C /etc/mail

    Create a file named: /etc/mail/genericstable
    with this inside it: root [email protected]
    (do not replace [email protected] with your own data)

    Execute this:
    makemap hash /etc/mail/genericstable < /etc/mail/genericstable

    and run:

    makemap hash /etc/mail/authinfo < /etc/mail/authinfo

    and make authinfo readable only by root:
    chmod 600 /etc/mail/authinfo

    This did it for me. I can send emails using my ISP's outgoing mail server with my FC6 server.


    POSTFIX

    I have not been able, so far, to find instructions on the web how to configure Postfix in the same manner as Sendmail. Alright, I have modified a line in /etc/postfix/main.cf to look like: relayhost = smtp.nicehost.com, but my web form didn't execute anything besides telling me the mail was sent, which wasn't the case.

    I'm not amazed that it doesn't work because no authentication method was set up.

    Any suggestions how to get it working for Postfix?
     
  7. bidevi

    bidevi New Member

    PHP mail form in Fedora Core 6: yes

    Earlier I wrote:

    My ISP is 1&1 in Germany and they have strange habits. For example, I cannot get a PHP mail form script working (...)

    I have just tried the form on my FC6 server and the PHP mail form worked fine (the mail was sent and received), so what I've stated earlier about 1&1 is wrong.

    The mail form did not work on Debian Etch (The Perfect Setup), which is on the same LAN behind the same router. Neither did it work on my Mac OS X (PPC) Apache server.

    I wonder why that is. Could it be that PHP on my FC6 machine has different PHP modules installed which are needed for PHP mail forms?

    Does anybody have a clue where to look for clues?
     
  8. falko

    falko Super Moderator Howtoforge Staff

    Take a look here: http://www.howtoforge.com/postfix_relaying_through_another_mailserver
     
  9. bidevi

    bidevi New Member

    Probably solved

    My postfix/sendmail problems seemed to be caused by the fact that I had 2 PCs running next to each other. When I switched the first one off, sendmail started working OK on PC #2, probably because port 25 was now free. I'll check postfix later.
     
  10. bidevi

    bidevi New Member

    How long should one keep on solving a problem?

    OK, so this is what I've got today:

    1. Debian Etch installed (Perfect Setup) on my trial server #2
    2. Postfix modified according to these guidelines: http://www.howtoforge.com/postfix_relaying_through_another_mailserver
    3. My mail form cgi script points to: /usr/sbin/sendmail
    4. When I send mail through my web page I get an OK but no mail is ever sent (again!)
    5. Server #1 is switched off so there is no interference

    When server #1 is doing the job everything is going well with sendmail on FC6, so I assume there is nothing wrong with my mail form.

    How long should one keep on solving a problem which shouldn't exist?

    Thanx for any help anyway.
     
  11. falko

    falko Super Moderator Howtoforge Staff

    What's in the mail log when this happens?
     
  12. bidevi

    bidevi New Member

    I cannot tell you that

    I cannot tell you (yet) what's in the mail log because I removed Debian and reinstalled Fedora Core 6 to reproduce the sendmail/smarthost configuration once again.

    Unfortunately, I failed, because all of the sudden FC6 told me its mirror sources were exhausted or something like that.

    So I tried Debian Etch's Perfect Setup again, but unfortunately I never got passed the moment where I have to give the mysql myserver.mydomain.com root password. This problem has been addressed in this forum but the solution in the earlier case was not suitable for me.

    I'll get back to this issue later, but I've got to get one thing off my chest: I am a long time Mac user (since 1986) and I am beginning to come to the conclusion that Linux is the solution for people with a lot of patience and time who cannot afford a Mac.
     
  13. bidevi

    bidevi New Member

    Check this PHP form

    1. Where can I check my mail log?

    2. Download and check this PHP mail form script:
    http://www.lekkah.com/mailz.zip
    (edit the mailz.php file: put your own mail address above the line written in capitals in order to receive and check the test mail you'll send).

    The PHP mail script (also Perl scripts) runs flawlessly on PC1 with FC6. On PC2 I have Debian Etch installed, perfect setup, with ISPConfig. I didn't do anything differently in those two cases, but neither PHP nor CGI form mail work on PC2. I get the success message but no mail is ever received.

    For me this is crucial, because I use form mail on my websites. If I cannot get it to work with Debian Etch I'll be stuck with FC6 for the rest of my life.

    Appreciate your help.
     
  14. bidevi

    bidevi New Member

    One more clue

    In case someone runs into the same problem as I did, here is a new development.

    On PC1 I've got FC6 running. Formmail works.

    On PC2 I tried several distro's. Even when I tried to reproduce PC1's FC6 installation, Formmail might work one time but the next time it might not. At this moment I'm lucky again: formmail works.

    What did I change? When I installed Fedora 7, I made sure that the domain name I chose was the same one as the one on PC1. So if PC1 is abc.dummy.com, then PC2 is now xyz.dummy.com.

    What's so important about the domain name in a LAN situation if no further connections depend on it? I'm not sure. My ISP is 1und1 and it could be that once their system excepts domain dummy.com they refuse domain dummier.com and any other domain name for the same customer.

    If anyone has a better explanation, please, be my guest.
     
  15. bidevi

    bidevi New Member

    Solved

    Installed Debian Etch - The Perfect Setup on my second PC with the same domain name as the first PC.

    That made the difference: formmail is working.

    Thank me!
     

Share This Page