PDA

View Full Version : Looking for PHP Mail script


Coley
16-05-2007, 00:55/12:55AM
Looking for a good PHP Mail script. Have been wading through all the online site scripts and just getting more and more confused so have come to where I know I get good advice :-)

Appreciate any recommendations

TIA
Coley

musketeer
23-06-2007, 12:20/12:20PM
here a simple solution it use's php's mail feature "mail()"


you need to change the name of the script in <form action=script_name.php>

also add the username var.

do apologise for if the script is basic or non working i made it in the reply box on the forum :)

i can add validation for you if need etc but this should work

<?

if(isset($_POST['send'])){
$username = $set-as-your-username-var;
$subject = $_POST['subject'] or die("Subject Blank");
$message = $_POST['message'] or die("Message Black");
$to = $_POST['to'] or die("No email set");
$headers = 'From: '.$username;
mail($to, $subject, $message, $headers)
echo "Mail sent to $to<br>\r\n";
}else{

echo "<form action=SCRIPT_NAME.php method=post>";
echo "<table>";
echo "<tr><td>Subject:</td><td><input type=text name=subject size=20 ></td></tr>";
echo "<tr><td>To:</td><td><input type=text name=to size=20 ></td></tr>";
echo "<tr><td>Message:</td><td><textarea rows=16 cols=45 name=message></textarea></td></tr>";
echo "<input type=hidden name=send></input>";
echo "<tr><td><button type=submit>Send Mail!</button></td></tr>";
echo "</table>";
echo "</form>";
}
?>

ihelpyou
23-06-2007, 16:27/04:27PM
Thanks musketeer.

Sheesh. Sorry Coley. I see your post was made over a month ago. I'm surprised no one saw it. Sorry.

musketeer
24-06-2007, 05:17/05:17AM
no worrys just returning the favor {websavey you know what i mean lol}

Coley
26-06-2007, 02:32/02:32AM
Thanks Musketer and apologies for taking so long to say thanks.

I have just returned to this form task - flat out being 'Jill of All Trades', you know how it goes, and don't get much time to visit as regularly as I would like :-)

But thanks for the code example, much appreciated.

Cheers,
Coley

WebSavvy
26-06-2007, 03:07/03:07AM
Yep, I missed it too, Doug. Sorry, Coley -- I haven't really been around much been super busy (but have popped in on & off).

Thanks for helping her out, musketeer.

musketeer
26-06-2007, 05:25/05:25AM
Originally posted by Coley
Thanks Musketer and apologies for taking so long to say thanks.

I have just returned to this form task - flat out being 'Jill of All Trades', you know how it goes, and don't get much time to visit as regularly as I would like :-)

But thanks for the code example, much appreciated.

Cheers,
Coley

not a problem :)

you might notice a few syntax errors like

mail($to, $subject, $message, $headers)

is missing the ending ;

mail($to, $subject, $message, $headers);

if you need any minor changes etc dont worry about asking... just let me know what you need it to do :)

Coley
26-06-2007, 06:35/06:35AM
Thanks again and yes, I will definitely let you know if I need any help :-)

Cheers,
Coley