PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old August 8th, 2004, 11:35 AM
saintflashx saintflashx is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Location: St. Kitts
Posts: 3 saintflashx User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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>

Reply With Quote
  #2  
Old August 8th, 2004, 12:23 PM
kode_monkey kode_monkey is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 367 kode_monkey User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 m 21 sec
Reputation Power: 6
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-

Reply With Quote
  #3  
Old August 8th, 2004, 03:27 PM
saintflashx saintflashx is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Location: St. Kitts
Posts: 3 saintflashx User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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.

Reply With Quote
  #4  
Old August 8th, 2004, 04:55 PM
kode_monkey kode_monkey is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 367 kode_monkey User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 m 21 sec
Reputation Power: 6
As far as I know there is no other alternative, could be wrong though, maybe someone else will have a suggestion.

-KM-

Reply With Quote
  #5  
Old August 8th, 2004, 05:33 PM
Itsacon's Avatar
Itsacon Itsacon is offline
Command Line Warrior
Click here for more information. Click here for more information
 
Join Date: Aug 2004
Location: Sector ZZ9 Plural Z Alpha
Posts: 992 Itsacon User rank is Lance Corporal (50 - 100 Reputation Level)Itsacon User rank is Lance Corporal (50 - 100 Reputation Level)Itsacon User rank is Lance Corporal (50 - 100 Reputation Level)  Folding Points: 732741 Folding Title: Super Ultimate Folder - Level 2Folding Points: 732741 Folding Title: Super Ultimate Folder - Level 2Folding Points: 732741 Folding Title: Super Ultimate Folder - Level 2Folding Points: 732741 Folding Title: Super Ultimate Folder - Level 2Folding Points: 732741 Folding Title: Super Ultimate Folder - Level 2Folding Points: 732741 Folding Title: Super Ultimate Folder - Level 2Folding Points: 732741 Folding Title: Super Ultimate Folder - Level 2
Time spent in forums: 6 Days 13 h 37 m 16 sec
Reputation Power: 5
Send a message via ICQ to Itsacon
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:
 ini_set("SMTP""smtp.server.address"); 

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

Reply With Quote
  #6  
Old August 8th, 2004, 11:12 PM
saintflashx saintflashx is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Location: St. Kitts
Posts: 3 saintflashx User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanks for the tip! I'm relieved that it is possible! Is there any special area in my code where this should be placed?

Reply With Quote
  #7  
Old August 9th, 2004, 02:17 AM
Itsacon's Avatar
Itsacon Itsacon is offline
Command Line Warrior
Click here for more information. Click here for more information
 
Join Date: Aug 2004
Location: Sector ZZ9 Plural Z Alpha
Posts: 992 Itsacon User rank is Lance Corporal (50 - 100 Reputation Level)Itsacon User rank is Lance Corporal (50 - 100 Reputation Level)Itsacon User rank is Lance Corporal (50 - 100 Reputation Level)  Folding Points: 732741 Folding Title: Super Ultimate Folder - Level 2Folding Points: 732741 Folding Title: Super Ultimate Folder - Level 2Folding Points: 732741 Folding Title: Super Ultimate Folder - Level 2Folding Points: 732741 Folding Title: Super Ultimate Folder - Level 2Folding Points: 732741 Folding Title: Super Ultimate Folder - Level 2Folding Points: 732741 Folding Title: Super Ultimate Folder - Level 2Folding Points: 732741 Folding Title: Super Ultimate Folder - Level 2
Time spent in forums: 6 Days 13 h 37 m 16 sec
Reputation Power: 5
Send a message via ICQ to Itsacon
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)

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > Help sending form via PHP


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway