Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > Linux Forums > Programming/Scripts

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Thread Tools Display Modes
Old 23rd June 2006, 19:29
mancho mancho is offline
Junior Member
Join Date: Jun 2006
Location: Dallas, TX
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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:

$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:

thanks for any assistance. I'm using ISPConfig and I LOVE IT!

Reply With Quote
Sponsored Links
Old 24th June 2006, 04:46
geek.de.nz geek.de.nz is offline
Join Date: Feb 2006
Posts: 65
Thanks: 0
Thanked 2 Times in 2 Posts
Send a message via ICQ to geek.de.nz Send a message via MSN to geek.de.nz

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
$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. ;-)

Ubuntu 5.10 with custom kernel (2.6.16-suspend2),
Debian Sarge 3.1 and Etch

Please submit your ISP or Webhost to (free)
Reply With Quote
Old 24th June 2006, 16:17
falko falko is offline
Super Moderator
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 41,701
Thanks: 1,900
Thanked 2,749 Times in 2,579 Posts

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
Download the ISPConfig 3 Manual! | Check out the ISPConfig 3 Billing Module!

FB: http://www.facebook.com/howtoforge

nginx-Webhosting: Timme Hosting | Follow me on:
Reply With Quote
Old 8th August 2006, 17:07
themachine themachine is offline
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():


        $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:

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.
Reply With Quote


Thread Tools
Display Modes

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
2 domains, 1 site wadims Installation/Configuration 13 31st May 2006 01:21
Problem with the apache (I can't start ist) M.Behrens Installation/Configuration 11 31st March 2006 11:48
Downgrade php5 to php4.4.2 llizards Installation/Configuration 4 14th March 2006 00:58
all my site go to /var/www/ Absolusteph Installation/Configuration 14 11th March 2006 22:27
PHP form mail error.... pjm2211 Installation/Configuration 5 3rd November 2005 19:20

All times are GMT +2. The time now is 11:38.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.