Yet another sendmail thread!

Discussion in 'Web Design and Development' started by Spinal, Mar 7, 2007.

  1. Spinal macrumors newbie

    Mar 7, 2007
    Howdy! First post on this thread, I've been "forwarded" to this forum from another forum I frequent (mbclub) - and am having a few issues setting up sendmail on a OsX box. First and foremost, let me be blunt - I've never set up sendmail before, and am really stumbling in the dark. All I need is a way to send messages to a couple of members of the IT team whenever a user posts a request for help or equipment.

    I've enabled PHP and mysql on one of the boxes I'm administering. The box runs as an internal-website (i.e. DNS entry on our internal DNS server, but no ip/port forwarding specifically to the box so the outside world can't "see" the box).

    The box runs OsX (10.4.8); apache (some version) (neither installed by me) - and now Apache's php and mysql add-ons. I configured php and mysql this afternoon, and both are working quite happily. php I did as such (in httpd.conf)

    LoadModule php4_module libexec/httpd/
    AddModule mod_php4.c
    AddType application/x-httpd-php .php
    AddType application/x-httpd-php-source .phps
    <IfModule mod_dir.c>
    DirectoryIndex index.html index.php index.htm
    Now, I typed up a quick html page; something on the lines of:
    <form method="get" action="sendmail.php"><br />
    Email: < input name="email" type="text" /><br/>
    Message:<textarea name="message" rows="10" cols="30"></textarea><br />
    <input type="submit" /></form>
    and a quick php script:
    <?$email = $_GET['email'] ;
    $message = $_GET['message'] ;
    mail( "***@***", "Email Subject", $message, "From: $email" );
    print "Mail Sent";
    (the *** replace my email at work)

    Now, if I give the whole thing a blast, it happily replies with "Mail Sent" - which is good... php hasn't crashed, no errors, bla bla...

    BUT... nothing ever comes through on the mail client side... I've tried alternative email addresses... nada... My first idea was that as the box is behind a proxy, the proxy might be filtering everything out (the proxy is set up in such a way that EVERYTHING needs to go through a specific IP:pORT to get to the outside world)... But the box is configured to go through that proxy (and can connect to the net). Does apache or *nix's sendmail have their own proxy configs?

    My second thought went down the lines of the ISP wanting us to use their SMTP server, double checked - thats not the case. We have a leased line and simply put, have almost no restrictions other than bandwidth...

    If not, any ideas? I'm at a total loss...

    Thanks in advance,

    p.s. sorry about the typos, its been a long day and I'm quite far from a cup of coffee...
  2. mnkeybsness macrumors 68030


    Jun 25, 2001
    Moneyapolis, Minnesota
    I'm not quite sure about server issues, but you might try using a POST form action and sending the correct header information and formatting the message...

    $_POST['email'] ;
    $message wordwrap($_POST['message'], 76"\n");

    $headers     "MIME-Version: 1.0\n";
    $headers    .= "From: $name <$email>\n";
    $headers    .= "Content-Type: text/plain; charset=\"utf-8\"\n";

    mail"***@***""Email Subject"$message$headers);
    These are merely best practices, as far as I know...
  3. Spinal thread starter macrumors newbie

    Mar 7, 2007
    Thanks for the reply. I used GET because I can edit the data in the URL and fiddle with it alot faster, I'll change it to post once it works... That can't be killing the script (php gets the data, I checked).

    Now, I've done some changes:
          $toEmail = $_GET['toEmail'] ; // variable declarations and initialisations from GET
    	  $fromEmail = $_GET['fromEmail'];
          $message = $_GET['message'] ;
    	  $subj = $_GET['subject'];
    	  $headers     = "MIME-Version: 1.0\n";
    	  $headers    .= "From: $fromEmail <$fromEmail>\n";
    	  $headers    .= "Content-Type: text/plain; charset=\"utf-8\"\n";
          mail( $toEmail, $subj, $message, $headers );
          print "Congratulations your email has been sent to $toEmail from $fromEmail <br /> Re: $subj <br>$message";
    I realise the subject isn't sent... but don't really care! I'm starting to think that sendmail needs to be configured to see "through" our proxy, but I can't find a coherent manual on sendmail... Might pass by the bookstore later!

    (still doesn't work...)
  4. nomade macrumors member


    Dec 2, 2006
    This is the script I have been using on numerous web site and various servers with success. Proxy should'nt be a problem since the script is interpreted by the server wich provide the parameters for the mail command.

    $to = "";
    $sujet = "subject line";

    //--- la structure du mail ----//

    $from = "From:$email\n";
    $from .= "MIME-version: 1.0\n";
    $from .= "Content-type: text/html; charset= iso-8859-1\n";

    //--- un exemple de message avec corps en html ---//
    $message="<table width=500><tr><td>Name: $name</td></tr><tr><td>Email: $email</td></tr><tr><td>The message: $text</td></tr></table>";

    //--- on envoie l'email ---//

    echo "<div align=center>Thanks ! $name<br><br>Your email have been sended</div>";

Share This Page