Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Senior Coder
    Join Date
    May 2006
    Posts
    1,673
    Thanks
    28
    Thanked 4 Times in 4 Posts

    Trying to get mail() function to work - any ideas ?

    I have been trying to use the following code to send an email out after someone fills in a form:

    Code:
    /*
    *  make MESSAGE  
    */     
    
    $messageX = "testing";
    
    /*
    *  send MESSAGE  
    */     
    
    // multiple recipients
    $to  = $N_email;
    
    // subject
    $subject = "As Promised ...Your Free Access to LETS GET STARTED.";
    
    // To send HTML mail, the Content-type header must be set
    $headers  = "MIME-Version: 1.0  \r\n";
    $headers .= "Content-type: text/html; charset=iso-8859-1 \r\n";
    
    // Additional headers
    $headers .= "From: Lets-Get-Started. <Admin@lets-get-started.net> \r\n";
        
    // Mail it
    mail($to, $subject, $messageX, $headers);
    
    echo "To: $to, Subject: $subject, Headers: $headers, Message: $messageX";
    
    if (mail($to, $subject, $messageX, $headers) == false) 
    {
     echo "Email failed";
    }
    
    ?>
    Is there anything wrong with code ?

    The code does not error - but just does not send anything

    The result from the echo stmt:is :

    To: kevin@intaccs.com,
    Subject: As Promised ...Your Free Access to LETS GET STARTED.,
    Headers: MIME-Version: 1.0 Content-type: text/html; charset=iso-8859-1
    From: Lets-Get-Started. ,
    Message: test


    Well I cant see anything wrong.

    The "if / false" does not echo anything

    Is there something I should check with my hosting account ?
    I have a shared hosting and have access to cPanel and even the WHM ( I have a reseller account)

    Thanks again for any help
    If you want to attract and keep more clients, then offer great customer support.

    Support-Focus.com. automates the process and gives you a trust seal to place on your website.
    I recommend that you at least take the 30 day free trial.

  • #2
    Regular Coder
    Join Date
    Nov 2005
    Location
    North Canton, Ohio
    Posts
    118
    Thanks
    11
    Thanked 4 Times in 4 Posts
    Requirements

    For the Mail functions to be available, PHP must have access to the sendmail binary on your system during compile time. If you use another mail program, such as qmail or postfix, be sure to use the appropriate sendmail wrappers that come with them. PHP will first look for sendmail in your PATH, and then in the following: /usr/bin:/usr/sbin:/usr/etc:/etc:/usr/ucblib:/usr/lib. It's highly recommended to have sendmail available from your PATH. Also, the user that compiled PHP must have permission to access the sendmail binary.

    Do you meet those?

  • #3
    Senior Coder
    Join Date
    May 2006
    Posts
    1,673
    Thanks
    28
    Thanked 4 Times in 4 Posts
    Thanks for your reply.

    I ran phpinfo.php and got this information.

    open_basedir /home/letsget/:/usr/lib/php:/usr/local/lib/php:/tmp
    include_path .:/usr/lib/php:/usr/local/lib/php

    sendmail_path /usr/sbin/sendmail -t -i
    SMTP localhost
    smtp_port 25

    Does that mean I have access to what I need for mail() ?

    Do I need to change the include_path at all ?

    Thanks again
    If you want to attract and keep more clients, then offer great customer support.

    Support-Focus.com. automates the process and gives you a trust seal to place on your website.
    I recommend that you at least take the 30 day free trial.

  • #4
    Regular Coder
    Join Date
    Jan 2006
    Posts
    189
    Thanks
    1
    Thanked 0 Times in 0 Posts
    PHP Code:
    // To send HTML mail, the Content-type header must be set
    $headers  "MIME-Version: 1.0  \r\n";
    $headers .= "Content-type: text/html; charset=iso-8859-1 \r\n"
    you are missing a period in the first one.. not sure if thats causing the problem, but its worth checking


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •