Page 1 of 1

Mail fuction not working

Posted: Sun Apr 17, 2005 3:28 pm
by 2bran
Hi guys,

I have a bit of a sticky problem right now i'm trying to send an e-mail from a php script and unfortualy it doesn't work.

PHP script

Code: Select all

<?php

$mail_to= $_POST['Email'];
$mail_subject= $_POST['Subject'];
$mail_message= $_POST['Content'];

if

 
(mail($mail_to,$mail_subject,$mail_message))or die(mysql_error());
 echo "Successfully sent the e-mail \"$mail_subject\" to $mail_to.";

 else
 
 echo "The message was unable to be sent to \"$mail_to\" with the message subject \"$mail_subject\".";
 

 
 ?>
Every time i run it the else message appears and when i used the or die sql query this error appears Parse error: parse error, unexpected T_LOGICAL_OR in /var/www/html/william/Call Center/mailtest.php on line 10.

I've been looking on the net and people suggsted about the SMTP settings in the php.ini file but they seem to be fine.

Any suggestions would be cool

Posted: Sun Apr 17, 2005 3:38 pm
by feyd
the 'or die' part is outside the "if" expression.

As for why it's not working.. there can be many reasons: The server you are sending to denies the email as spam or something; Your server isn't properly set up to send mail; sendmail isn't installed or is misconfigured; etc..

Posted: Sun Apr 17, 2005 3:42 pm
by 2bran
sendmail is running because i checked the service status, also i forgot to mention i had this working before but i was running red hat now i've upgraded to fedora could that make a difference?

On the subject of configuring sendmail it seem fine. bit of mystery!!