Closed Thread
Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: php mail() function...

  1. #1
    jamesclavel60 is offline x10Hosting Member jamesclavel60 is an unknown quantity at this point
    Join Date
    May 2011
    Posts
    9

    php mail() function...

    hi admins,

    i have written a simple script to test PHP mail function to send out email... i just use my personal email for the recipient and used the mail() function...

    i have read from a thread replied by: stpvoice
    that it needs a header \"content-type\" set to text/plain for the mail() function to work...

    script goes like this...

    <?php
    $to = \"username@server.com\";
    $subject = \"Test mail from x10hosting\";
    $message = \"Hello! This is a simple email message.\";
    $from = \"support@myx10hosting.bz\";

    $headers = \"MIME-Version: 1.0\" . \"\\r\\n\";
    $headers .= \"Content-type:text/plain; charset=iso-8859-1\" . \"\\r\\n\";
    $headers .= \"From:\" . $from . \"\\r\\n\";

    //mail($to,$subject,$message,$headers);
    if(mail($to,$subject,$message,$headers)){
    echo \"Mail Sent.\";
    }else{
    echo \"ERROR sending mail\";
    }

    ?>

    i tried executing the script on my free hosting account.... but it prints \"ERROR sending mail\"

    hope to be clarified on this scenario.... i also have checked on the specs for free hosting the \"PHP sendmail\" is ticked and means that it\'s activated by default.

    best regards,

    James

  2. #2
    stpvoice's Avatar
    stpvoice is offline Community Support Rep stpvoice has a brilliant futurestpvoice has a brilliant futurestpvoice has a brilliant future
    Join Date
    Dec 2008
    Location
    United Kingdom
    Posts
    5,939

    Re: php mail() function...

    Hello,

    This is the script I use to test mail. I just checked and it works fine on your server:
    Code:
    <?php
    $to  = 'email@domain' . ', ';
    
    $subject = 'Your subject';
    
    $message = '
    Test message. Send by me from me.
    ';
    
    $headers  = 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-type: text/plain; charset=iso-8859-1' . "\r\n";
    
    $headers .= 'To: FName LName <emai@domain>' . "\r\n";
    $headers .= 'From: FName LName <email@domain>' . "\r\n";
    
    if (mail($to,$subject,$message,$headers) ) {
           echo "Email sent!";
        } else {
           echo "Email sending failed!";
    };
    ?>
    Fill in the details, and try.
    Last edited by stpvoice; 05-22-2011 at 01:03 PM.


  3. #3
    jamesclavel60 is offline x10Hosting Member jamesclavel60 is an unknown quantity at this point
    Join Date
    May 2011
    Posts
    9

    Re: php mail() function...

    hi stpvoice,

    thanks for the prompt response... OK i will try the code you posted and will let you know the outcome...

    thanks so much.. appreciate your promptness!

    best regards,

    james

    ---------- Post added at 06:13 PM ---------- Previous post was at 06:05 PM ----------

    hi stpvoice,

    i tried the code you posted me, filled-out the details and run the script on the browser, unfortunately the echoed message was "Email sending failed!"

    by the way, kindly check once again, here's my server "chopin"

    thanks in advance!

    best regards,

    James

  4. #4
    stpvoice's Avatar
    stpvoice is offline Community Support Rep stpvoice has a brilliant futurestpvoice has a brilliant futurestpvoice has a brilliant future
    Join Date
    Dec 2008
    Location
    United Kingdom
    Posts
    5,939

    Re: php mail() function...

    Hello,

    Still works for me. Could you pastebin a copy of the modified script for me to look at?
    I checked on your server before. We can see which server an account is on etc.

    Thanks.
    Last edited by stpvoice; 05-22-2011 at 01:19 PM.


  5. #5
    jamesclavel60 is offline x10Hosting Member jamesclavel60 is an unknown quantity at this point
    Join Date
    May 2011
    Posts
    9

    Re: php mail() function...

    hi stpvoice,

    kindly check the code here:

    http://pastebin.com/ivR5jKQN

    kindly run the script on my server, and i'll check if i received the email.

    best regards,

    James

  6. #6
    stpvoice's Avatar
    stpvoice is offline Community Support Rep stpvoice has a brilliant futurestpvoice has a brilliant futurestpvoice has a brilliant future
    Join Date
    Dec 2008
    Location
    United Kingdom
    Posts
    5,939

    Re: php mail() function...

    Hello,

    I just ran that script and it worked with no issues, echoing: "Email sent!"
    Please check your email and let me know if you received it.

    Thanks.


  7. #7
    jamesclavel60 is offline x10Hosting Member jamesclavel60 is an unknown quantity at this point
    Join Date
    May 2011
    Posts
    9

    Re: php mail() function...

    hi stpvoice,

    yes i have received the email, this is odd for me... coz i really can't see the problem... i have tried resetting my safari browser before running the script... i will pastebin the url on the simple script with the same code... and let me know on your end if it echo "Email sent!"

    http://pastebin.com/txsGjXgQ

    best regards,

    James

  8. #8
    stpvoice's Avatar
    stpvoice is offline Community Support Rep stpvoice has a brilliant futurestpvoice has a brilliant futurestpvoice has a brilliant future
    Join Date
    Dec 2008
    Location
    United Kingdom
    Posts
    5,939

    Re: php mail() function...

    Hello,

    That one does not work.
    It's probably not a server issue seeing as I can use a script that works on all of the other servers to send you a message.

    Thanks.


  9. #9
    jamesclavel60 is offline x10Hosting Member jamesclavel60 is an unknown quantity at this point
    Join Date
    May 2011
    Posts
    9

    Re: php mail() function...

    can u send me a url of the simple script you made under "chopin" server that i could test? using the same code I have give earlier with my email address so i can verify... url must be under the same server "chopin"

    or maybe since i'm only using a "FREE" hosting... is this a limitation?

    best regards,

    James

  10. #10
    stpvoice's Avatar
    stpvoice is offline Community Support Rep stpvoice has a brilliant futurestpvoice has a brilliant futurestpvoice has a brilliant future
    Join Date
    Dec 2008
    Location
    United Kingdom
    Posts
    5,939

    Re: php mail() function...

    Hello,

    As I said before, this is the script I use: http://pastebin.com/yy0WjHeF
    I tested it from a free hosting account. Chopin is an entirely free hosting server.
    It wouldn't matter where the command comes from, the important thing is the way the server processes it.

    Thanks.
    Last edited by stpvoice; 05-22-2011 at 02:13 PM.


Closed Thread
Page 1 of 2 12 LastLast

Similar Threads

  1. PHP Mail notifications
    By cbminstrel80 in forum Free Hosting
    Replies: 3
    Last Post: 05-22-2011, 08:20 PM
  2. Setting Up Mail Client
    By tjrana0 in forum Free Hosting
    Replies: 1
    Last Post: 05-21-2011, 06:59 PM
  3. php mail
    By jonvfelosi25 in forum Free Hosting
    Replies: 1
    Last Post: 05-16-2011, 04:55 PM
  4. php mail function
    By rashid100_200081 in forum Free Hosting
    Replies: 0
    Last Post: 05-16-2011, 04:25 PM
  5. PHP mail function
    By r.c.diablo43 in forum Free Hosting
    Replies: 0
    Last Post: 05-16-2011, 08:07 AM

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