MAMP, PHP, email(), postfix... config question.

Discussion in 'Web Design and Development' started by toddburch, Aug 16, 2007.

  1. toddburch macrumors 6502a

    Joined:
    Dec 4, 2006
    Location:
    Katy, Texas
    #1
    I wasn't sure which forum to put this in - and figured this was as good as any.

    I downloaded and installed MAMP. Seems to be working fine.

    I've written a .php form. It displays fine. I keep it in MAMP/htdocs just like MAMP requires.

    When I click submit, the email() function returns TRUE, but the mail never goes out.

    Researching this some, I found the error log (the bounced email) in /var/mail/ in a file named toddburch (my machine name). The error says this:
    (I edited my email address to say "myuserid")

    Code:
     
    From MAILER-DAEMON  Thu Aug 16 12:57:24 2007
    Return-Path: <>
    X-Original-To: toddburch@todd-burchs-computer.local
    Delivered-To: toddburch@todd-burchs-computer.local
    Received: by todd-burchs-computer.local (Postfix)
    	id 1EACB20B460; Thu, 16 Aug 2007 12:57:24 -0500 (CDT)
    Date: Thu, 16 Aug 2007 12:57:24 -0500 (CDT)
    From: MAILER-DAEMON@todd-burchs-computer.local (Mail Delivery System)
    Subject: Undelivered Mail Returned to Sender
    To: toddburch@todd-burchs-computer.local
    MIME-Version: 1.0
    Content-Type: multipart/report; report-type=delivery-status;
    	boundary="30CF720B45A.1187287044/todd-burchs-computer.local"
    Message-Id: <20070816175724.1EACB20B460@todd-burchs-computer.local>
    
    This is a MIME-encapsulated message.
    
    --30CF720B45A.1187287044/todd-burchs-computer.local
    Content-Description: Notification
    Content-Type: text/plain
    
    This is the Postfix program at host todd-burchs-computer.local.
    
    I'm sorry to have to inform you that your message could not be
    be delivered to one or more recipients. It's attached below.
    
    For further assistance, please send mail to <postmaster>
    
    If you do so, please include this problem report. You can
    delete your own text from the attached returned message.
    
    			The Postfix program
    
    <myuserid@mac.com>: host smtp-mx5.mac.com[17.250.244.61] said: 553 5.1.8
        <toddburch@todd-burchs-computer.local>... Domain of sender address
        toddburch@todd-burchs-computer.local does not exist (in reply to MAIL FROM
        command)
    
    --30CF720B45A.1187287044/todd-burchs-computer.local
    Content-Description: Delivery report
    Content-Type: message/delivery-status
    
    Reporting-MTA: dns; todd-burchs-computer.local
    X-Postfix-Queue-ID: 30CF720B45A
    X-Postfix-Sender: rfc822; toddburch@todd-burchs-computer.local
    Arrival-Date: Thu, 16 Aug 2007 12:57:22 -0500 (CDT)
    
    Final-Recipient: rfc822; myuserid@mac.com
    Action: failed
    Status: 5.0.0
    Diagnostic-Code: X-Postfix; host smtp-mx5.mac.com[17.250.244.61] said: 553
        5.1.8 <toddburch@todd-burchs-computer.local>... Domain of sender address
        toddburch@todd-burchs-computer.local does not exist (in reply to MAIL FROM
        command)
    
    --30CF720B45A.1187287044/todd-burchs-computer.local
    Content-Description: Undelivered Message
    Content-Type: message/rfc822
    
    Received: by todd-burchs-computer.local (Postfix, from userid 501)
    	id 30CF720B45A; Thu, 16 Aug 2007 12:57:22 -0500 (CDT)
    To: myuserid@mac.com
    Subject: Membership
    From: myuserid@mac.com
    Reply-To: myuserid@mac.com
    X-Mailer: PHP/5.2.3
    Message-Id: <20070816175722.30CF720B45A@todd-burchs-computer.local>
    Date: Thu, 16 Aug 2007 12:57:22 -0500 (CDT)
    
    Sign me up!
    Todd Burch
    myuserid@mac.com
    This is a textarea box. 
    line 2 
    line 3.
    Thanks!  Connie.
    
    --30CF720B45A.1187287044/todd-burchs-computer.local--
    
    So, the error says my domain is not valid, and I have to agree. Searching the net, I found a few hits about this, and found one approach that suggested I sudo pico etc/hostconfig to add a HOSTNAME=myuserid@mac.com.

    I tried that, and got another error (It's all getting foggy now - this was done late last night). I backed that change out, as I noticed the info was 5 years old (circa 2002, and for Panther - I'm running Tiger).

    Before doing the pico to hostconfig, I tried a sudo hostname=myuserid@mac.com and if I remember correctly, both this and the hostconfig change added the needed FROM: info in the email. But, I also changed my .php file to add an additional "From: " header at the same time. So... who knows.

    Can anyone help straighten this out for me? It's not overwhelming, but there's a whole lot of config going on here that is untrodden turf for me.

    Thanks, Todd

    (If needed, I can supply my .php file and the php.ini file as well)


    EDIT - I typed email() and I should have typed mail(), referring to the PHP builtin function.
     
  2. Super Macho Man macrumors 6502a

    Super Macho Man

    Joined:
    Jul 24, 2006
    Location:
    Hollywood, CA
    #2
    I don't have direct experience with this problem, but I believe you need to change some settings in your php.ini. Changing your Mac's hostname would probably also work, but is more of a hack than a solution.

    http://php.net/mail
     
  3. toddburch thread starter macrumors 6502a

    Joined:
    Dec 4, 2006
    Location:
    Katy, Texas
    #3
    Yeah, thanks for the link. I think I've read that 20 times now.

    After too many hours of getting frustrated with MAMP's paradigm - I ditched it.

    I figured out how to modify Apache (that came with OS X) to serve a .php file (easy), and modifying the default php.ini file (actually, copying the php.ini.default to php.ini and modiying that one) to complete the sendmail_from, specifying the -f value, it works great!

    So, my form is functional, and now I need to upgrade Apache, upgrade PHP, and then install MySQL.

    Thanks, Todd
     
  4. quitesurreal macrumors newbie

    Joined:
    Jun 30, 2005
    Location:
    Austin
    #4
    settings that finally worked for me

    The information here was close enough to help, but I had to use a slight variant. In MAMP's MAMP\conf\php5 (as i am using php5) directory, I edited the php.ini file and set the [mail function] info to:

    [mail function]
    ; For Win32 only.
    ;SMTP = localhost
    ;smtp_port = 25

    ; For Win32 only.
    ;sendmail_from = me@example.com

    ; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
    sendmail_path =/usr/sbin/sendmail -t -i -f myemail@mydomain.com

    Obviously, the email address needs to be a real email address that you wish to use. Then stop/start MAMP. The test email (testemail.php) page contents which is located in my MAMP/htdocs/test is:

    <?php
    $efrom = "From: fromemailaddress@domainname.com\r\n";
    mail(
    'toemailaddress@domainname.com', // your email address
    'Test', // email subject
    'This is an email sent from MAMP', // email body
    $efrom . "\r\n"// additional headers
    );
    ?>

    On my system, I opened a browser and entered:

    http://localhost:8888/test/testemail.php

    I hope this is useful to others.
     
  5. nicodv macrumors newbie

    Joined:
    Jan 25, 2011
    #5
    i can´t make it work

    Hello, the changes proposed doesn´t work for me (i´m a beginner in this) I´m changing all the email addresses from the php.ini and still i doesn´t respond.

    ; For Win32 only.
    ;SMTP = localhost
    ;smtp_port = 25

    ; For Win32 only.
    ;sendmail_from = me@example.com

    ; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
    sendmail_path =/usr/sbin/sendmail -t -i -f myemail@mydomain.com

    Any other tip to try? What other thing should i revise in order to make it work?

    Thank you very much

    Nicodv
     
  6. gmopinillosv macrumors newbie

    Joined:
    Jan 26, 2011
    #6
    Maybe this needs to buy MAMP PRO because both MAMP and MAMP PRO are different.
     

Share This Page