php mail() function...

Status
Not open for further replies.

jamesclavel60

New Member
Messages
9
Reaction score
0
Points
0
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
 

stpvoice

Community Support Rep
Community Support
Messages
5,987
Reaction score
212
Points
63
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:

jamesclavel60

New Member
Messages
9
Reaction score
0
Points
0
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
 

stpvoice

Community Support Rep
Community Support
Messages
5,987
Reaction score
212
Points
63
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:

stpvoice

Community Support Rep
Community Support
Messages
5,987
Reaction score
212
Points
63
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.
 

jamesclavel60

New Member
Messages
9
Reaction score
0
Points
0
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
 

stpvoice

Community Support Rep
Community Support
Messages
5,987
Reaction score
212
Points
63
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.
 

jamesclavel60

New Member
Messages
9
Reaction score
0
Points
0
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
 

stpvoice

Community Support Rep
Community Support
Messages
5,987
Reaction score
212
Points
63
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:

jamesclavel60

New Member
Messages
9
Reaction score
0
Points
0
i had to resolve the setback by using PHPMailer using SMTP to send mail rather using the default mail() function... it worked fine, thanks for the responses though...

-james
 
Status
Not open for further replies.
Top