|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Help sending form via PHP
Hi,
I've tried several times tweaking code to send a simple form to my email address via php. Problem is - I never get the message. Could someone please point out my error? I've copied the php script below. I'd appreciate any assistance you could give. Thanks. <html> <head><title>Feedback</title></head> <body> <?php // Handle POST method. if ($_POST) { $name = $_POST['name']; $email = $_POST['email']; $comments = $_POST['comments']; // Compose text message: $message = "Message from $name ($email)\n\nComments:\n\n$comments"; // Send message mail("saintflashx@yahoo.com", "Feedback", $message); // Message sent confirmation echo "<h1>Message sent successfully!h1>\n"; } else { ?> <h1>Feedback</h1> <form action="<?= $PHP_SELF ?>" method="post"> <p>Name: <input type="text" name="name" /></p> <p>Email: <input type="text" name="email" /></p> <p>Comments:</p> <p><textarea name="comments"></textarea></p> <p><input type="submit" value="Send!" /></p> </form> <?php } ?> </body> </html> |
|
#2
|
|||
|
|||
|
More than likely you don't have an smtp set up. Theres been another thread on this recently. Have a look through and it should answer your question.
-KM- |
|
#3
|
|||
|
|||
|
Thanks for your quick assistance. I had a look through the threads but none offered a solution if no smtp setup was done. The site I'm working on is being hosted remotely and I have no access or authority to set up an smtp server. Does this mean that I cannot use the php mail function? Is the any way to use the function without smtp??? Thanks for your help.
|
|
#4
|
|||
|
|||
|
As far as I know there is no other alternative, could be wrong though, maybe someone else will have a suggestion.
-KM- |
|
#5
|
||||
|
||||
|
Actually, it IS possible, with the ini_set() function.
This allows you to change environment variables during runtime. The way to do this in your case is to use the following function call: PHP Code:
Where you replace smtp.server.address with the address of a PUBLIC smtp server, so not one that checks for source IP's, which is the case with most ISP mail servers. You'll simply have to try this out, and search around a bit for a suitable server. If you find one, let me know, a public mail server can alway come in handy ![]() |
|
#6
|
|||
|
|||
|
Thanks for the tip! I'm relieved that it is possible! Is there any special area in my code where this should be placed?
|
|
#7
|
||||
|
||||
|
Well, before calling the mail() function, of course
![]() But for the rest not really, SMTP is one of the envvars that can be changed anywhere, because it is exterior (php does not connect to the smtp server till it needs to send mail) |
![]() |
| Viewing: Dev Articles Community Forums > Programming > PHP Development > Help sending form via PHP |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|