
23rd June 2006, 19:29
|
|
Junior Member
|
|
Join Date: Jun 2006
Location: Dallas, TX
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Newbie: Creating a simple php form email, how?
Sorry if answered, I couldn't find it.
I need to create a simple "send form" that processes an email (its sent to a remote listserv).
I couldn't get it to work with this:
<?php
$to = "listserv-on@mail.baskins.com";
$subject = "Baskins Email Signup";
$from = "txtEmail";
if (mail($to, $subject, $from)) {
echo("<p>Message successfully sent!</p>");
} else {
echo("<p>Message delivery failed...</p>");
}
?>
What am I doing wrong? THe form is here: http://www.baskins.com/email_sign_up.html
and posts to:
http://www.baskins.com/emailprocess.php
thanks for any assistance. I'm using ISPConfig and I LOVE IT!
mancho
|

24th June 2006, 04:46
|
|
Member
|
|
Join Date: Feb 2006
Posts: 65
Thanks: 0
Thanked 2 Times in 2 Posts
|
|
Maybe you don't have 'register_globals = On' in your php.ini, which would make this not work.
However, you can access form variables with
Code:
$txtEmail = $_GET['txtEmail'];
// or
$txtEmail = $_POST['txtEmail'];
depending on the method of the form (default GET). You should use POST for a lot of data, so e.g. if you're sending a text-area values.
The mail syntax looks right for me.
__________________
Always mention at least your distribution/version! You can add it in your signature if you don't want to always type it. ;-)
Distributions:
Ubuntu 5.10 with custom kernel (2.6.16-suspend2),
Debian Sarge 3.1 and Etch
Please submit your ISP or Webhost to (free)
http://www.ihostnz.com
|

24th June 2006, 16:17
|
|
Super Moderator
|
|
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 31,843
Thanks: 781
Thanked 1,557 Times in 1,476 Posts
|
|
Quote:
|
Originally Posted by mancho
if (mail($to, $subject, $from)) {
|
Your usage of the mail function is wrong. Have a look here: http://de.php.net/manual/en/function.mail.php
|

8th August 2006, 17:07
|
|
Senior Member
|
|
Join Date: Oct 2005
Location: Texas, USA
Posts: 109
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Yes, Falko is right... the following is the basic usage of mail():
Code:
<?php
$my_addy = "user@domain.com";
$to_addy = "otheruser@otherdomain.com";
$subject = "Test Subject";
$message = "Test Message";
$headers = "From: $my_addy \r\n";
$headers .= "Reply-To: $my_addy \r\n";
$headers .= "Return-Path: $my_addy \r\n";
mail ($to_addy,$subject,$message,$headers);
?>
If you wanted to check the return of mail(), you could make it:
Code:
...
if(mail($to_addy,$subject,$message,$headers)) {
print "Mail sent OK";
} else {
print "Mail did not send properly";
}
...
But this is only checking whether "mail()" returned without error.... it has nothing to do with whether the email got anywhere successfullly.
__________________
themachine
5dollarwhitebox.org
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT +2. The time now is 13:52.
|
Recent comments
5 hours 20 min ago
10 hours 35 min ago
10 hours 47 min ago
10 hours 54 min ago
11 hours 56 min ago
14 hours 4 min ago
16 hours 29 min ago
16 hours 48 min ago
16 hours 56 min ago
18 hours 11 min ago