Here ya go, try something like this, it's from a form mailer script I
wrote.
Macroit
//better to check the var, than get php errors
$hidSubmit = (isset($_POST['hidSubmit'])) ? $_POST['hidSubmit']:'';
if(isset($hidSubmit)){
$mail_to=$txtEmailto;
$mail_from=$txtEmailfrm;
$mail_sub=$txtSub;
$mail_mesg=$txtMsg;
// add in some form post validation, or your script might be abused
$ret = SendMsg($txtSub, $txtMsg, $txtEmailto, $txtEmailfrm, '', '',
$txtEmailfrm);
if($ret) {
echo "<span class='textred'>E-mail has been sent successfully from
$mail_sub to $mail_to</span>";
} else {
echo "<span class='textred'>Failed to send the E-mail from $mail_sub
to $mail_to</span>";
}
} // end if(isset($hidSubmit)){
function SendMsg($sm_subject, $sm_message, $sm_msgto, $sm_msgfrom,
$sm_msgcc, $sm_msbcc, $sm_replyto) {
if (!checkemail($sm_msgfrom)) {
$sm_msgfrom = $sm_msgto;
}
$headers = "To: $sm_msgto\n";
$headers .= "From: $sm_msgfrom\n";
if ($sm_msgcc!='') {
$headers .= "CC: $sm_msgcc\n";
}
if ($sm_msbcc!='') {
$headers .= "BCC: $sm_msbcc\n";
}
$to = $sm_msgto ;
if ($sm_replyto!='') {
$headers .= "Reply-To:$sm_replyto\n";
} else {
// '* No return e-mail address was provided';
}
$headers .= "MIME-Version: 1.0\n";
$headers .= "Content-type: text/plain; charset=iso-8859-1\n";
$headers .= "X-Mailer: PHP/" . phpversion();
$headers .= "X-Priority: 3\n";
// set subject to something if not already set, done else where
//$subject = 'some default subject';
if (mail($to, $sm_subject, $sm_message, $headers)) {
$ret = true;
} else {
$ret = false;
}
return $ret;
}
function checkemail($chk_email) {
$chk_email = trim($chk_email);
if
(!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)[EMAIL PROTECTED](\
.[a-z0-9-]+)*(\.[a-z]{2,3})$",
$chk_email)) {
$result=false;
} else {
$result=true;
}
return $result;
}
--- In [email protected], ahmed sirag <[EMAIL PROTECTED]> wrote:
>
> Hi, I have a problem in sending email from php form.
>
> I use the following page to send mail
>
> http://www.talentlogo.com/asp/send3.php
>
> But unfortunately no thing was sent, I have attached the source code
to you and I hope that you can help me.
>
> <?php
>
> //Check whether the submission is made
> if(isset($hidSubmit)){
>
> //Declarate the necessary variables
> $mail_to=$txtEmailto;
> $mail_from=$txtEmailfrm;
> $mail_sub=$txtSub;
> $mail_mesg=$txtMsg;
>
> //Check for success/failure of delivery
>
if(mail($mail_to,$mail_sub,$mail_mesg,"From:$mail_
from/r/nReply-to:$mail_from"))
> echo "<span class='textred'>E-mail has been sent successfully from
$mail_sub to $mail_to</span>";
> else
> echo "<span class='textred'>Failed to send the E-mail from $mail_sub
to $mail_to</span>";
> }
> ?>
>
> <form name="frmsendmail" method="post" action="" onSubmit="return
ValidationForm()">
> <table width="100%" border="0">
> <tr>
> <td width="33%" align="right" class="text">To :
> <td width="67%"><input name="txtEmailto" type="text"
class="input" id="txtEmailto22" size="30" maxlength="100">
> </tr>
> <tr>
> <td align="right" class="text">From :
> <td><input name="txtEmailfrm" type="text" class="input"
id="txtEmailfrm22" size="30" maxlength="100">
> </tr>
> <tr>
> <td align="right" class="text">Subject :
> <td><input name="txtSub" type="text" class="input"
id="txtSub22" size="30" maxlength="100">
> </tr>
> <tr>
> <td align="right" class="text">Mesage(body) :
> <td><textarea name="txtMsg" cols="50" rows="10"
class="input" id="textarea"></textarea>
> </tr>
> <tr>
> <td align="right"><input name="hidSubmit" type="hidden"
id="hidSubmit" value="true">
> <input name="Submit" type="submit" class="input"
value="Send">
> <td><input name="Submit2" type="reset" class="input"
value="Reset">
> </tr>
> </table>
> </form>
>
>
>
>
>
>
>
> Regards
> Ahmed Sirag
> __________________________________________________
> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
>
> [Non-text portions of this message have been removed]
------------------------ Yahoo! Groups Sponsor --------------------~-->
<font face=arial size=-1><a
href="http://us.ard.yahoo.com/SIG=12hfg7eun/M=362335.6886445.7839731.1510227/D=groups/S=1705375618:TM/Y=YAHOO/EXP=1124472959/A=2894361/R=0/SIG=13jmebhbo/*http://www.networkforgood.org/topics/education/digitaldivide/?source=YAHOO&cmpgn=GRP&RTP=http://groups.yahoo.com/">In
low income neighborhoods, 84% do not own computers. At Network for Good, help
bridge the Digital Divide!</a>.</font>
--------------------------------------------------------------------~->
The php_mysql group is dedicated to learn more about the PHP/MySQL web database
possibilities through group learning.
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/php_mysql/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/