Mail fuction not working

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
2bran
Forum Commoner
Posts: 38
Joined: Fri Mar 04, 2005 7:03 pm

Mail fuction not working

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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..
2bran
Forum Commoner
Posts: 38
Joined: Fri Mar 04, 2005 7:03 pm

Post 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!!
Post Reply