Closed Thread
Results 1 to 4 of 4

Thread: Php Mail

  1. #1
    blackviperofdeath86 is offline x10Hosting Member blackviperofdeath86 is an unknown quantity at this point
    Join Date
    Jun 2011
    Posts
    4

    Php Mail

    I'm trying to use Php's mail() function, but no emails seem to send. I had a co-worker test the code with his server (GoDaddy), and it sent the email for him. I looked, and it appears that the function is setup, but is there an additional step I need to do in order for the function to work properly?

  2. #2
    descalzo's Avatar
    descalzo is offline Grim Squeaker descalzo has a brilliant futuredescalzo has a brilliant futuredescalzo has a brilliant future
    Join Date
    Jul 2009
    Location
    Ankh-Morpork
    Posts
    7,635

    Re: Php Mail

    The following works on Chopin. It even gets to Hotmail (you might have to check the Spam folder, at least it does not get bounced back).

    PHP Code:
    <?php


    //  TEST OF THE MAIL SYSTEM USING PHP mail()

    date_default_timezone_set('America/Los_Angeles');
    echo 
    date('l jS \of F Y h:i:s A'); 
    echo 
    "\n";

    $from "myX10cPanelName@myX10domain.x10.bz";
    $to="myGMAILaccount@gmail.com"


    $mailbody="Test message sent (PST): \n" date('l jS \of F Y h:i:s A');
    $subject="Test of PHP mail()" ;

    $headers "Content-type: text/plain; charset=windows-1251 \r\n";
    $headers .= "From: $from\r\n";
    $headers .= "Reply-To: $from\r\n";
    $headers .= "MIME-Version: 1.0\r\n";
    $headers .= "X-Mailer: PHP/" phpversion();

    $resp mail($to$subject$mailbody$headers);

    if( 
    $resp ){
        
    $outcome "Mail sent" ;
    } else {
        
    $outcome "Mail not sent";
    }

    print 
    "\nThe mail system said: $outcome\n\n" ;
    exit();
    Note: Content-type must be text-plain
    Note: From header must be an account on your site.
    Nothing is always absolutely so.

  3. #3
    blackviperofdeath86 is offline x10Hosting Member blackviperofdeath86 is an unknown quantity at this point
    Join Date
    Jun 2011
    Posts
    4

    Re: Php Mail

    I have a similar code:

    $to = "<EMAIL ADDRESS HERE>";
    $subject = "test email";
    $from = "From: Webhost<donotreply@email.com>";
    $message="This is a test email.";

    $mail = mail($to,$subject,$message,$from);

    but this doesn't seem to work, and my spam folder is empty.
    I tested this with both yahoo and hotmail.

    Quote Originally Posted by descalzo View Post
    Note: From header must be an account on your site.
    Does this necessarily have to be true? The test that my co-worker ran worked just fine, and it's a non-existent email account.

    also, my server uses boro?

    Hosting package adfree-infinity
    Server Name boru
    cPanel Version 11.30.2 (build 1)
    Theme x3
    Apache version 2.2.19
    PHP version 5.3.6
    MySQL version 5.1.57-rel12.8
    Architecture x86_64
    Operating system linux
    Path to sendmail /usr/sbin/sendmail
    Last edited by blackviperofdeath86; 08-14-2011 at 01:29 AM.

  4. #4
    blackviperofdeath86 is offline x10Hosting Member blackviperofdeath86 is an unknown quantity at this point
    Join Date
    Jun 2011
    Posts
    4

    Re: Php Mail

    Ok, I see why it didn't work. The from field does have to be from the domain, but the user does not have to be.

    Other than that, it does not have to be in plain text either (It's just a specifier)

Closed Thread

Similar Threads

  1. Replies: 0
    Last Post: 06-29-2011, 02:54 PM
  2. Replies: 1
    Last Post: 10-04-2010, 02:46 PM
  3. form mail problem - sends but can't receive mail
    By scotlundy in forum Free Hosting
    Replies: 0
    Last Post: 02-11-2010, 10:04 AM
  4. Replies: 1
    Last Post: 09-30-2009, 10:52 AM
  5. Replies: 3
    Last Post: 12-03-2007, 08:56 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers