| | |
Form mail, how to make it work?
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Apr 2009
Posts: 7
Reputation:
Solved Threads: 0
HI, DOES ANY ONE KNOW WHAT IS THE RIGHT STEPS TO MAKE THIS FORM MAIL TO WORK?
HE IS THE CODE:
1. <html>
2. <head>
3. <title> send mailf from the form </title>
4. </head>
5. <body>
6. <?php
7. echo "<p> your name is: <b>$_POST[name]</b>,</p>";
8. echo "<p> your Email address is: <b>$_POST[email]</b></p>";
9. echo "<p> Your message was: <br>";
10.echo "$_POST[message]</p>";
11. $msg ="Name: $_POST[name]\n";
12. $msg .="Email: $_POST[email]\n";
13. $msg .="message: $_POST[message]\n";
14. $recipient = "ero100@live.com";
15. $mailheaders ="reply-to: $_POST[email]";
16. mail($recipient, $subject, $msg, $mailheaders);
17. ?>
18. </body>
19.</html>
HE IS THE ERROR MESSAGE:
your name is: Mr. Jhonh,
your Email address is: Myemail@hotmail.co.uk
Your message was:
what is this error???? CANT FIGURE IT OUT...
Notice: Undefined variable: subject in C:\wamp\www\phptest\listing9.11.php on line 19
Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\wamp\www\phptest\listing9.11.php on line 19
HE IS THE CODE:
1. <html>
2. <head>
3. <title> send mailf from the form </title>
4. </head>
5. <body>
6. <?php
7. echo "<p> your name is: <b>$_POST[name]</b>,</p>";
8. echo "<p> your Email address is: <b>$_POST[email]</b></p>";
9. echo "<p> Your message was: <br>";
10.echo "$_POST[message]</p>";
11. $msg ="Name: $_POST[name]\n";
12. $msg .="Email: $_POST[email]\n";
13. $msg .="message: $_POST[message]\n";
14. $recipient = "ero100@live.com";
15. $mailheaders ="reply-to: $_POST[email]";
16. mail($recipient, $subject, $msg, $mailheaders);
17. ?>
18. </body>
19.</html>
HE IS THE ERROR MESSAGE:
your name is: Mr. Jhonh,
your Email address is: Myemail@hotmail.co.uk
Your message was:
what is this error???? CANT FIGURE IT OUT...
Notice: Undefined variable: subject in C:\wamp\www\phptest\listing9.11.php on line 19
Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\wamp\www\phptest\listing9.11.php on line 19
A few observations:
1. When you post code, you should use [code] tags to have it format properly.
2. You don't need the <html> <head> and <body> statements. PHP takes care of that.
3. $subject on line 16 isn't defined (at least in what you have shown us).
4. The default is that mail doesn't actually get sent from the local (test) environment. It can be done but you will have to make some changes (if you need this, I'm sure that you can find references from an internet search).
1. When you post code, you should use [code] tags to have it format properly.
2. You don't need the <html> <head> and <body> statements. PHP takes care of that.
3. $subject on line 16 isn't defined (at least in what you have shown us).
4. The default is that mail doesn't actually get sent from the local (test) environment. It can be done but you will have to make some changes (if you need this, I'm sure that you can find references from an internet search).
•
•
•
•
A few observations:
1. When you post code, you should use [code] tags to have it format properly.
2. You don't need the <html> <head> and <body> statements. PHP takes care of that.
3. $subject on line 16 isn't defined (at least in what you have shown us).
4. The default is that mail doesn't actually get sent from the local (test) environment. It can be done but you will have to make some changes (if you need this, I'm sure that you can find references from an internet search).
WAMP/XAMP does not come with an SMTP server so you'll have to configure the php.ini file to point to another SMTP server.
And as noted before, you haven't set the
$subject variable to anything. GCS d- s+ a-->? C++(++++) UL+++ P+>+++ L+++ E--- W+++
N+ o K w++(---) O? !M- V PS+>++ PE+ Y+ PGP !t- 5? X- R tv+
b+>++ DI+ D G++>+++ e+ h+>++ r y+
PMs asking for help will not be answered, post on the forums. That's what they're there for.
N+ o K w++(---) O? !M- V PS+>++ PE+ Y+ PGP !t- 5? X- R tv+
b+>++ DI+ D G++>+++ e+ h+>++ r y+
PMs asking for help will not be answered, post on the forums. That's what they're there for.
•
•
Join Date: Apr 2009
Posts: 37
Reputation:
Solved Threads: 2
Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\wamp\www\phptest\listing9.11.php on line 19
..This error occured because u are running the application on your local machine ,ie local host and no mail server is set up on your local machine .Upload your file to some server and it will work fine because the mail server will be there in the sever .
..This error occured because u are running the application on your local machine ,ie local host and no mail server is set up on your local machine .Upload your file to some server and it will work fine because the mail server will be there in the sever .
To solve the first e_notice error, simply assign a value to the $subject variable before sending the mail and as for the second error, as previously mentioned it means that the mail function cannot connect to the wamp mail service. So to solve that first error the code will be as follows:
So to solve the rest, it will require resetting up a localhost mail server on your computer but the above script should be fine.
php Syntax (Toggle Plain Text)
<html> <head> <title> send mailf from the form </title> </head> <body> <?php echo "<p> your name is: <b>".$_POST['name']."</b>,</p>"; echo "<p> your Email address is: <b>".$_POST['email']."</b></p>"; echo "<p> Your message was: <br>"; echo $_POST['message']."</p>"; $msg ="Name: ".$_POST['name']."\n"; $msg .="Email: ".$_POST['email']."\n"; $msg .="message: ".$_POST['message']."\n"; $recipient = "ero100@live.com"; $mailheaders ="reply-to: ".$_POST['email']; $subject='subject'; //this was added mail($recipient, $subject, $msg, $mailheaders); ?> </body> </html>
Last edited by cwarn23; Apr 27th, 2009 at 7:06 am.
Try not to bump 10 year old threads as it can be really annoying.
http://syntax.cwarn23.net/
My favourite PC. - Oopy Doopy Do 2U2!
http://syntax.cwarn23.net/
Smilies: ^_* +_+ v_v -_- *~*` My favourite PC. - Oopy Doopy Do 2U2!
![]() |
Similar Threads
- form to mail problem (HTML and CSS)
- form to mail problem (PHP)
- Contact form Flash/PHP sends with Text Formatting (PHP)
- Email Form ? (HTML and CSS)
- email form problem (Web Hosting Deals)
- Problems in Dynaform (Form Mail) URGENT HELP (PHP)
- instant calculcated quote form (PHP)
- Action against Amamax for selling bad power supply (Troubleshooting Dead Machines)
Other Threads in the PHP Forum
| Thread Tools | Search this Thread |
Tag cloud for PHP
# .htaccess 5.2.10 access ajax apache api array beginner binary broken cakephp checkbox class cms code cron curl database date directory display dissertation download dynamic echo email error file files folder form forms function functions google href htaccess html image images include insert integration ip java javascript joomla ldap legislation limit link login loop mail menu mlm mod_rewrite multiple mysql mysqlquery oop open parse paypal pdf persist php problem query radio random recursion regex remote script search server sessions sms soap sockets source space sql structure syntax system table tutorial update upload url validation validator variable video web xml youtube






