didgydont Posted May 28, 2008 Share Posted May 28, 2008 hi all im having a strange problem that when i send to different emails from the one form it sends 2 copys of the same email to the person in the to section the person in the cc section only gets one and its only the second email does this the first email sent send 1 copy to both the to and cc section. does any one know why this happens or how to make it only send one <?php include("passwdpage.php");?> <html> <head> <title>demo Onsite Form</title> <link rel="stylesheet" type="text/css" href="site.css" /> </head> <?php if (empty($_POST['tech'])){ $dandt = date('d/m/Y'); echo "<P ALIGN='center'><img src='demo.JPG' alt='Demo onsite service sheet'></P> <h2 class='bluetext' ALIGN='center'>Onsite Service Report</h2> <table border='0' cellpadding='5' cellspacing='0' align='center'> <form action='index.php' method='post'> <tr><td class='bluetext'>Your Name:</td><td> <select type='text' name='tech' class='quoteselect'> <option value='andy'>Andy</option> <option value='daniel'>Daniel</option> <option value='fady'>Fady</option> <option value='jarrod'>Jarrod</option> <option value='leigh'>Leigh</option></select></td></tr> <tr><td class='bluetext'>Client Or Company:</td><td><input type='text' name='client' class='quoteselect' /></td></tr> <tr><td class='bluetext'>Address:</td><td><input type='text' name='address' class='quoteselect' /></td></tr> <tr><td class='bluetext'>Phone Number:</td><td><input type='text' name='phone' class='quoteselect' /></td></tr> <tr><td class='bluetext'> </td><td></td></tr> <tr><td class='bluetext'>Work Performed:</br></br></br></br></br></br></br></br></br></td><td><textarea class='quoteselect' cols='20' rows='10' name='work' id='work'></textarea></td></tr> <tr><td class='bluetext'> </td><td></td></tr> <tr><td class='bluetext'>Parts Used:</br></br></td><td><textarea class='quoteselect' cols='20' rows='3' name='parts' id='parts'></textarea></td></tr> <tr><td class='bluetext'> </td><td></td></tr> <tr><td class='bluetext'>Parts to be ordered:</br></br></td><td><textarea class='quoteselect' cols='20' rows='3' name='orderparts' id='orderparts'></textarea></td></tr> <tr><td class='bluetext'> </td><td></td></tr> <tr><td class='bluetext'>Time and date:</td><td class='bluetext'>In:<input type='text' name='timein' class='pricebox' /> Out:<input type='text' name='timeout' class='pricebox' /> Date:<input type='text' name='servicedate' value='$dandt' class='datebox' /></td></tr> <tr><td></td><td><input type='submit' class='quoteselect' VALUE='Send job to Accounts' /></td></tr></form>"; } else { echo "<P ALIGN='center'><img src='demo.JPG' alt='Demo onsite service sheet'></P>"; if ($_POST['tech'] == "andy"){ $techemail = "[email protected]"; $techname = "Andy F";} elseif ($_POST['tech'] == "daniel"){ $techemail = "[email protected]"; $techname = "Daniel N";} elseif ($_POST['tech'] == "fady"){ $techemail = "[email protected]"; $techname = "Fady A";} elseif ($_POST['tech'] == "jarrod"){ $techemail = "[email protected]"; $techname = "Jarrod K";} elseif ($_POST['tech'] == "leigh"){ $techemail = "[email protected]"; $techname = "Leigh D";} else {echo "no name how is this possible"; exit;} if (empty($_POST['client'])){echo"<p ALIGN='center'><b class='bluetexterror'>Sorry $techname we at least need a customer or company name <A class='error' HREF='http://demo.com.au/onsite/index.php'> Go Back!!!</A></B></p>"; exit;} else{echo"</br>";} $client = $_POST['client']; if (empty($_POST['address'])){$address = "not filled out";} else {$address = $_POST['address'];} if (empty($_POST['phone'])){$phone = "not filled out";} else {$phone = $_POST['phone'];} if (empty($_POST['work'])){$work = "not filled out";} else {$work = $_POST['work'];} if (empty($_POST['parts'])){$parts = "not filled out";} else {$parts = $_POST['parts'];} if (empty($_POST['timein'])){$timein = "not filled out";} else {$timein = $_POST['timein'];} if (empty($_POST['timeout'])){$timeout = "not filled out";} else {$timeout = $_POST['timeout'];} if (empty($_POST['servicedate'])){$servicedate = "not filled out";} else {$servicedate = $_POST['servicedate'];} $to = "[email protected]"; $subject = "Onsite job by $techname"; $message = " Hi accountant This email is to let you know that $techname has done onsite work for $client Location: $address Contact Number:$phone ------------------------------------------------------------------------------ The work performed:$work ------------------------------------------------------------------------------ Parts used:$parts ------------------------------------------------------------------------------ Time in:$timein Time out:$timeout Date of Service:$servicedate "; $headers = "From: $techemail\r\n"; $headers .= "Reply-To: $techemail\r\n"; $headers .= "Return-Path: $techemail\r\n"; $headers .= "CC: $techemail\r\n"; $sent = mail($to, $subject, $message, $headers) ; if($sent) {print "</br><p ALIGN='center' class='bluetext'>Thank you $techname your service report for $client was sent </br>successfully to the accounts department </br><A class='error' HREF='http://office.jc.com.au/onsite/index.php'> Go Back!!!</A></p>"; } else {print "</br><p ALIGN='center' class='bluetext'>We encountered an error sending your mail</p>"; } if (empty($_POST['orderparts'])){echo"</br>";} else{ $orderparts = $_POST['orderparts']; $toparts = "[email protected]"; $subjectparts = "please order these parts for $techname"; $messageparts = " Hi daniel can you please order the follow parts for $client ! $orderparts thanx $techname "; $headersparts = "From: $techemail\r\n"; $headersparts .= "Reply-To: $techemail\r\n"; $headersparts .= "Return-Path: $techemail\r\n"; $headersparts .= "CC: $techemail\r\n"; mail($toparts, $subjectparts, $messageparts, $headersparts) ; } } ?> <br /><br /> </html> Quote Link to comment https://forums.phpfreaks.com/topic/107720-wierd-error-when-sending-to-emails/ Share on other sites More sharing options...
.josh Posted May 28, 2008 Share Posted May 28, 2008 Well you have two mail function calls. One is inside a condition that's met simply by virtue of successfully being executed. The other one is being executed if $_POST['orderparts'] is not empty, so theoretically (I say theoretically because I didn't look at the rest of your code for other conditions etc...) if you fill out your form, it's going to execute both mail functions. Quote Link to comment https://forums.phpfreaks.com/topic/107720-wierd-error-when-sending-to-emails/#findComment-552221 Share on other sites More sharing options...
didgydont Posted May 29, 2008 Author Share Posted May 29, 2008 yes i know i want it that way so if the tech needs parts when the fill out the form the accountat gets the job and a defferent email gets sent to the purchaseing section of the company the problem is with the parts email not the job email the job sends 1 copy to the tech and accounts but for some reason when parts are ordered it sends the parts email to the tech 1 time wich is what i want but the purchase section (the email in the to section) get 2 copys instead of 1. so the second mail function sends 3 emails instead of the 2 Quote Link to comment https://forums.phpfreaks.com/topic/107720-wierd-error-when-sending-to-emails/#findComment-552229 Share on other sites More sharing options...
didgydont Posted May 29, 2008 Author Share Posted May 29, 2008 sorry i tested this to an outside account and it sent on copy only i think its a 602 bug sorry again Quote Link to comment https://forums.phpfreaks.com/topic/107720-wierd-error-when-sending-to-emails/#findComment-552250 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.