Php email form script doesn't work

I have a php script that i want to use on my site to send an email through a form from the site. But it doesn't work.
The form can be found at http://jordysoft.com/files/contactus.php

Can please someone take a look at the form to see what is wrong.

dia21Asked:
Who is Participating?
 
TheUnkindCommented:
ok try this, it checks the usermail if empty then it won't do anything but if it has a value it will send the form to jordysoft@yahoo.com, still you need a email checker if the email entered is valid :


<?php
 $myemail = "jordysoft@yahoo.com"; #change this to xx@jordysoft.com if you want to send it to this email

if (!empty($_POST['userEmail'])){
  echo "User Ip: ".$_POST['ip'];

  $todayis = date("l, F j, Y, g:i a") ;

  $subject = "Contact email from Jordysoft.com site" ;

$message = $todayis."[EST] \n
Message:". $_POST['userMessage']."\n
From:". $_POST['userName']."(".$_POST['userName'].")\n
Additional Info : IP =". $_POST['ip']." \n
Browser Info:". $_POST['httpagent']." \n
Referral :". $_POST['httpref']." \n";

$from = "From: $myemail\r\n";

   if (!mail($myemail, $subject, $message, $from)){
      echo "Unable to send email";
   }
}else{
 echo "Email is empty";
}
?>
0
 
hernst42Commented:
To track down the error we need to see the code of sendmail.php. The form looks ok
0
 
dia21Author Commented:
<?php
 $myemail = "jordysoft@yahoo.com";

if (!isset($userEmail))
echo "User Ip: $ip" ;

$todayis = date("l, F j, Y, g:i a") ;

$subject = "Contact email from Jordysoft.com site" ;

$message = " $todayis [EST] \n
Message: $userMessage \n
From: $userName ($userEmail)\n
Additional Info : IP = $ip \n
Browser Info: $httpagent \n
Referral : $httpref \n
";

$from = "From: $myemail\r\n";

if ($myemail != "")
mail($myemail, $subject, $message, $from);

?>

<b><p align=center>
Date: <?php echo $todayis ?>
<br>
Thank You : <?php echo $userName ?> ( <?php echo $userEmail ?> )
<br>
Your IP: <?php echo $ip ?>
0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

 
hernst42Commented:
The script looks okay. Can't see why it is not working.
you may add a check
if (!mail($myemail, $subject, $message, $from)) {
   echo "Sending mail failed maybe a safemode-problem?\n";
}

If that message apears you php-configuration is not correct for the mail-part
0
 
basiclifeCommented:
Is the SMTP server configured correctly? Is it your own server or someone else's?
0
 
TheUnkindCommented:
try this


<?php
 $myemail = "jordysoft@yahoo.com";

if (!isset($_POST['userEmail']))
echo "User Ip: $ip" ;

$todayis = date("l, F j, Y, g:i a") ;

$subject = "Contact email from Jordysoft.com site" ;

$message = $todayis."[EST] \n
Message:". $_POST['userMessage']."\n
From:". $_POST['userName']."(".$_POST['userName'].")\n
Additional Info : IP =". $_POST['ip']." \n
Browser Info:". $_POST['httpagent']." \n
Referral :". $_POST['httpref']." \n";

$from = "From: $myemail\r\n";
echo $message;
if ($myemail != "")
mail($myemail, $subject, $message, $from);

?>
0
 
TheUnkindCommented:
one more thing
change $ip to $_POST['ip']
0
 
TheUnkindCommented:
my bad... here's the latest

<?php
 $myemail = "jordysoft@yahoo.com";

if (!isset($_POST['userEmail']))
echo "User Ip: ".$_POST['ip'] ;

$todayis = date("l, F j, Y, g:i a") ;

$subject = "Contact email from Jordysoft.com site" ;

$message = $todayis."[EST] \n
Message:". $_POST['userMessage']."\n
From:". $_POST['userName']."(".$_POST['userName'].")\n
Additional Info : IP =". $_POST['ip']." \n
Browser Info:". $_POST['httpagent']." \n
Referral :". $_POST['httpref']." \n";

$from = "From: $myemail\r\n";   /*comment this is supposed to be the sender's email it should be: "From: ".$_POST['userEmail']; */

if ($myemail != "")
mail($myemail, $subject, $message, $from);

?>
0
 
dia21Author Commented:
hernst42,
i've put your code i don't get that message.

basiclife,
No is not my one server. I'm hosting with hollosite.com (100webspace.com). Here are the server information:

Operating system :      Debian GNU/Linux      
Perl Modules :      Click to View (NOTE: this page is over 450 KB)      
Perl version :      v5.8.4       
Perl path :      /usr/bin/perl       
Sendmail path :      /usr/sbin/sendmail       
MySQL version :      4.0.21-log       
PHP version :      4.3.4       
Physical IP address :      70.84.255.131      
Mysql host :      hollosite.com      
Mysql port :      3306      
POP3/IMAP (incoming mail server) :      mail.hollosite.com      
POP3 port :      110      
IMAP port :      443      
SMTP (outgoing mail server) :      mail.hollosite.com      
SMTP port :      25
Server type:      Apache


TheUnkind,
I've put your code still isn't working. Do i have to put  myemail the email that i set on the server.
e. g Instead of jordysoft@yahoo.com to put one of the emails xx@jordysoft.com. Does it matter this?

0
 
TheUnkindCommented:
>I've put your code still isn't working. Do i have to put  myemail the email that i set on the server.
>e. g Instead of jordysoft@yahoo.com to put one of the emails xx@jordysoft.com. Does it matter this?

as far as i know at your script it sends the form information to your yahoo.com email account, but if you want it to send to your own site email you can change the myemail to xx@jordysoft.com... May i know where would you want your contact form send the information? to your yahoo account or to the jordysoft account?
0
 
dia21Author Commented:
The email to be sent to yahoo account. I just asked you if it matter the email account.

i've put your new code but still i don't receive any email into my yahoo account.
If i leave empty the email address i get "Email is empty" and when i put an email i get no errors but the message i can't receive it.

Do i have to configure the mail path I've put the mail path in contact page but without any difference.
Can you take a look at the form page if is ok (if you didn't saw it)

http://jordysoft.com/files/contactus.php

I've run out of ideas ofn this:)
0
 
hernst42Commented:
THe only one thing to track that issue down would be to analyze the logs of the mailserver so you can see where the problem is. Is the mail send by php initial recieived by the mail-server or not. If this is not the case there might be a problem with you mail-settings with in php Can you post a link to a page where the phpinfo can b eview of that server.

If the mail is received by the mailserver this will be a problem with the mailserver and not with PHP.
0
 
dia21Author Commented:
I don't know were to search/give you the link for the logs. Here is the php configuration (i think) that i saved the file form my account http://jordysoft.com/php.html.

The site i have is hosted with http://100webspace.com free account. So i can make a new account and put the site on that and give you the username/pass to test it or if you have time maybe can you create a new account and see were is the pb.

Please help because i really need this to fix because i get for day to day many spam emails and i want to change my emails so i can hide the emails from the public.

0
 
TheUnkindCommented:
hey chief, i don't think my script has an error, but i guess 100webspace.com are the one who doesn't send an email. i signed up and put up a mail script but it doesn't sent any email to my yahoo account, even to my other mail accounts... if you want i can host it for you, mail me @ amitkronos@yahoo.com. thanks
0
 
TheUnkindCommented:
i mean hosting your script just to test it =)
0
 
dia21Author Commented:
TheUnkind, i send to you an email and i also send an email to 100webswpace.com about this problem. I wait the response to see if i get a solution of this problem.

Thanks
dia21
0
 
TheUnkindCommented:
basiclife, im so sorry... if there's a way to delete my email in this post that'll be very good.. Thank you
0
 
basiclifeCommented:
To my knowledge no. Not the end of the world :D I wasn't exactly in a position to solve the problem anyway but it's worth noting for future reference (also, SPAMers can get your email address from here so you might get totally inundated)
0
 
dia21Author Commented:
i received the email from 100webspace.com and they say that disabled this function for security reasons or something lke this. It seems that the script works.

Thank your for your comments and for your help.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.