mail form on a home server

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
twistbrain
Forum Newbie
Posts: 5
Joined: Thu Jan 30, 2003 10:11 am

mail form on a home server

Post by twistbrain »

i host a website on my pc and i want a mail form, but i cannot submit any forms.
this is the line where the error occurs:

mail($recipient, $subject, $msg, $mailheaders) or die ("Couldn't send mail!");

i think its something with smtp server, you can't send a mail out of nothing. is it possible to add a line or a script which will set a smtp?
im a noob at php so... :oops: :lol: !
twistbrain
Forum Newbie
Posts: 5
Joined: Thu Jan 30, 2003 10:11 am

Post by twistbrain »

here is the script where i wanna add something that will make it work on my server:

<?

// Copyright by filedesign.com 2001, 2002
// Information: Do not change the name of this file, it' ill not work !


// Configuration of recipient and subject.
$recipient = "yourmail@yourdomain.com";
$subject = "Contact Form";


// Please do not change anything below this line!!!
// ________________________________________________

$mailheaders = "From: <$sender_email> \n";
$mailheaders .= "Reply-To: <$sender_email>\n\n";

$msg = "_____________________________________________________________________\n";
$msg .= "Sender's Name: $sender_name\n";
$msg .= "\n";
$msg .= "Sender's E-Mail: $sender_email\n";
$msg .= "\n";
$msg .= "Company: $sender_company\n";
$msg .= "\n";
$msg .= "Website: $sender_website\n";
$msg .= "\n";
$msg .= "Message:\n\n$sender_message\n";
$msg .= "\n";
$msg .= "_____________________________________________________________________";

mail($recipient, $subject, $msg, $mailheaders) or die ("Couldn't send mail!");

?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
<TITLE>Form sent...</TITLE>

</HEAD>

<body bgcolor="white" text="black">
<div align=center>

<?
echo "<table border=0 width=400>\n";
echo "<tr><td colspan=2>You sent the following data:</td></tr>\n";
echo "<tr><td valign=top><b>Name:</b></td><td>$sender_name</td></tr>\n";
echo "<tr><td valign=top><b>E-Mail:</b></td><td>$sender_email</td></tr>\n";
echo "<tr><td valign=top><b>Company:</b></td><td>$sender_company</td></tr>\n";
echo "<tr><td valign=top><b>Website:</b></td><td>$sender_website</td></tr>\n";
echo "<tr><td valign=top><b>Message:</b></td><td>$sender_message</td></tr>\n";
echo "</table>\n";

?>

</div>

</body>
</html>
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Which OS are you using (and which version).

Mac
twistbrain
Forum Newbie
Posts: 5
Joined: Thu Jan 30, 2003 10:11 am

Post by twistbrain »

i am using windows 98SE, and my server runs on Apache, i dont know which version it is, i think not the new but the one before the newest version.
twistbrain
Forum Newbie
Posts: 5
Joined: Thu Jan 30, 2003 10:11 am

Post by twistbrain »

wait, i fixed the problem!

i changed lines in PHP.ini
on the lines:

[mail function]
SMTP=yoursmtpserver
Sendmail_from=yourmail@localhost.com
//and if you have a password protected SMTP mail, then add these lines:
username=yourusername
password=your password

i just made a guess and it worked :lol:
good for a newbie aight?!? :twisted:
Post Reply