hi i have a very serious problem..
i want to send a mail with resume attachments.the hitch is that the attachments should come directly from the server. i am passing the can_id of the candidates whose resumes i need to pull from db and attach with the mail.
i have tried a lot but am stuck n this is very imp.
if some1 can help then i'll be very grateful.
am attaching the files with the code.
thanks in advance,
Suk
view.php
send.phpCode:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> </head> <body> <a href="send.php?count=4&arrid=1,2,3,4">Send</a> </body> </html>
sendmailpro.phpCode:<?php include("db.php") ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html > <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <link rel="stylesheet" href="js/menu.css"> <title>Employ Me - Send General mail</title> <script src="images/Validations.js" type="text/javascript"></script> <link rel="stylesheet" href="images/styles.css" type="text/css"> <link href="images/styles.css" rel="stylesheet" type="text/css" /> </head> <body leftmargin="2" topmargin="0" marginheight="2" marginwidth="0"> <table width="101%" height="50%" border="0" cellpadding="0" cellspacing="0" bgcolor="#F6F7F2"> <!-- First Row --> <tr> <td><?php //include("header.php") ?></td> </tr> <!-- First Row End --> <tr> <!-- Second Row End --> <td height="425" valign="top" bgcolor="f6f7f2"><div align="center"> <table width="100%" cellpadding="0" cellspacing="0"> <tr> <td align="center" class="bigfnt">Send General Mail to All Registered Candidates</td> </tr> </table> <br /> </div> <table width="97%" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#D0CDAE" > <tr> <td align="center"> <br><br> <?php $str=$_REQUEST['arrid']; $str1= (explode(",",$str)); if(trim($msg) != "") { echo "<span class=smallmsg> $msg </span><BR><BR>"; } ?> <form name="massmailfrm" method="post" action="sendmailpro.php?count=<?php echo $_GET['count']; ?>&id=<?php echo $str; ?>" enctype="multipart/form-data"> <table width="70%" border="1" cellpadding="0" cellspacing="0" bordercolor="#d0cdae"> <tr> <td><table width="100%" border="0" cellpadding="4" cellspacing="0" align="center"> <tr> <td align="left" class="fields">To</td> <td align="left" class="fields"><select name="to" id="to" onchange="document.massmailfrm.to1.value = document.massmailfrm.to.options[document.massmailfrm.to.selectedIndex].text; " > <option value="">Select Clients Email</option> <?php $clientemail= mysql_query("select distinct CMgmail from jobs"); while($clientemailrs = mysql_fetch_object($clientemail)) { ?> <option value="<?php echo $clientemailrs->CMgmail?>"><?php echo $clientemailrs->CMgmail?></option> <?php } ?> </select> <input name="to1" type="text" class="txtfield" id="to1" size="20" maxlength="45" /></td> </tr> <tr> <td align="left" class="fields">From </td> <td align="left" class="fields"><input id="from" name="from" type="text" size="25"> </td> </tr> <tr> <td align="left" class="fields">Subject </td> <td align="left" class="fields"><input id="mailsubj" name="mailsubj" type="text" size="50"> </td> </tr> <tr> <td width="30%" align="left" class="fields">Resumes </td> <td width="70%" align="left" class="fields"> <div id="resume"> <?php $content=""; for($i = 0; $i < count($str1); $i++){ $s=$str1[$i]; $result = mysql_query("select * from candidate where can_id='$s'")or die(mysql_error()); while($row = mysql_fetch_array( $result )) { ?><a href="<?php echo $row['resume_path']; ?> "><?php echo $row['can_id'];?></a> <?php } } ?></div> </td> </tr> <tr> <td width="30%" align="left" valign="top" class="fields">Message</td> <td width="70%" align="left" class="fields"><textarea name="mailmsg" cols="65" rows="8"></textarea> </td> </tr> <tr align="center"> <td></td> <td align="left"><input name="submit" type="submit" class="btn_style" onclick="return validatemail(this.form);" value="Submit" /> </td> </tr> </table></td> </tr> </table> </form> <br> <br> </td> </tr> </table></td></tr> <tr> <td height="15" valign="top" bgcolor="f6f7f2"><?php include("footer.php") ?></td> </tr> </table> </body> </html>
Code:<?php include("db.php"); $str=$_REQUEST['id']; $str1= (explode(",",$str)); for($i = 0; $i < count($str1); $i++){ $s=$str1[$i]; $result = mysql_query("select * from candidate where can_id='$s'")or die(mysql_error()); while($row = mysql_fetch_array( $result )) { $message= $_POST['mailmsg']."<br>"; $to=$_POST['to1']; $subject=$_POST['mailsubj']; echo $fname =$_SERVER['DOCUMENT_ROOT']."offshoreSuppliers.com/".$row['resume_path'];// your .doc file name //$fname =$_SERVER['DOCUMENT_ROOT'].$row['resume'];// your .doc file name $data = file_get_contents($file); $from = $_POST['from']; $mime_boundary = "<<<:" . md5(uniqid(mt_rand(), 1)); $type="Application/Octet-Stream"; $headers .= "MIME-Version: 1.0\r\n"; $headers .= "X-Priority: $priority\r\n"; $headers .= "Content-Type: multipart/mixed;\r\n"; $headers .= " boundary=\"" . $mime_boundary . "\"\r\n"; $headers .= "From: $from\r\n"; //$headers .= "Cc: ".$email_user; $mime = "This is a multi-part message in MIME format.\r\n"; $mime .= "\r\n"; $mime .= "--" . $mime_boundary . "\r\n"; $mime .= "Content-Transfer-Encoding: 7bit\r\n"; $mime .= "Content-Type: text/html; charset=\"iso-8859-1\"\r\n"; $mime .= "\r\n"; $mime .= $message . "\r\n\r\n"; $mime .= "--" . $mime_boundary . "\r\n"; $mime .= "Content-Transfer-Encoding: base64\r\n"; $mime .= "Content-Type: $type;\r\n"; $mime .=" name=\"$resume1\"\r\n"; $mime .= "Content-Disposition: attachment;\r\n "; $mime .= " name=\"$resume1\"\r\n\r\n"; $mime .= base64_encode($data) . "\r\n\r\n"; $mime .= "--" . $mime_boundary . "--\r\n"; if (mail($to, $subject, $mime, $headers)) $msg = "Mail has been sent successfully to the Client"; else $msg = "Error during mail sending. Please retry"; } } ?>



Reply With Quote
Bookmarks