[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Php email form script doesn't work

Posted on 2004-10-21
20
Medium Priority
?
335 Views
Last Modified: 2011-09-20
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.

0
Comment
Question by:dia21
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 6
  • 3
  • +1
20 Comments
 
LVL 48

Expert Comment

by:hernst42
ID: 12374076
To track down the error we need to see the code of sendmail.php. The form looks ok
0
 

Author Comment

by:dia21
ID: 12374385
<?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
 
LVL 48

Expert Comment

by:hernst42
ID: 12375653
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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 5

Expert Comment

by:basiclife
ID: 12377499
Is the SMTP server configured correctly? Is it your own server or someone else's?
0
 
LVL 2

Expert Comment

by:TheUnkind
ID: 12377790
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
 
LVL 2

Expert Comment

by:TheUnkind
ID: 12377795
one more thing
change $ip to $_POST['ip']
0
 
LVL 2

Expert Comment

by:TheUnkind
ID: 12377821
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
 

Author Comment

by:dia21
ID: 12383873
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
 
LVL 2

Expert Comment

by:TheUnkind
ID: 12387024
>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
 
LVL 2

Accepted Solution

by:
TheUnkind earned 200 total points
ID: 12387061
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
 

Author Comment

by:dia21
ID: 12388049
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
 
LVL 48

Expert Comment

by:hernst42
ID: 12394619
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
 

Author Comment

by:dia21
ID: 12394922
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
 
LVL 2

Expert Comment

by:TheUnkind
ID: 12397039
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
 
LVL 2

Expert Comment

by:TheUnkind
ID: 12397042
i mean hosting your script just to test it =)
0
 

Author Comment

by:dia21
ID: 12404812
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
 
LVL 5

Expert Comment

by:basiclife
ID: 12406366
0
 
LVL 2

Expert Comment

by:TheUnkind
ID: 12406746
basiclife, im so sorry... if there's a way to delete my email in this post that'll be very good.. Thank you
0
 
LVL 5

Expert Comment

by:basiclife
ID: 12407050
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
 

Author Comment

by:dia21
ID: 12415111
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

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to count occurrences of each item in an array.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question