jimmyh Posted November 5, 2008 Share Posted November 5, 2008 Hi, I am new to PHP and have written some code which processes a HTML form and sneds an email with attachment. However i now need to add another attachment which for all the want in the world i cant make send. The code below is the original code with one attachment sending, i have tried copying the code for attachment 1 to process attachment 2 with no joy, i have tried chaning the process method to an array still with no joy and for all the online classes in the world i am stuck. (the form code is below the PHP code. Any help would be greatly appreciated. /////////PHP Code/////////////// <?php $filename=$_FILES["strresume"]["name"]; $filetype=$_FILES["strresume"]["type"]; $filesize=$_FILES["strresume"]["size"]; $filetemp=$_FILES["strresume"]["tmp_name"]; if ($_POST['ProducingBroker'] == '') { $a1 = '<span style="color:red;">Producing Broker Omitted.</span>'; } else { $a1 = $_POST['ProducingBroker']; } if ($_POST['ClaimsHandlerName'] == '') { $a2 = '<span style="color:red;">Claims Handler Name Omitted.</span>'; } else { $a2 = $_POST['ClaimsHandlerName']; } if ($_POST['Email'] == '') { $a3 = '<span style="color:red;">Email Omitted.</span>'; } else { $a3 = $_POST['Email']; } if ($_POST['ContactNo'] == '') { $a4 = '<span style="color:red;">Contact No Omitted.</span>'; } else { $a4 = $_POST['ContactNo']; } if ($_POST['Policyholder'] == '') { $a5 = '<span style="color:red;">Policyholder Omitted.</span>'; } else { $a5 = $_POST['Policyholder']; } if ($_POST['InsuredName'] == '') { $a6 = '<span style="color:red;">Insured Name Omitted.</span>'; } else { $a6 = $_POST['InsuredName']; } if ($_POST['PolicyNumber'] == '') { $a7 = '<span style="color:red;">Policy Number Omitted.</span>'; } else { $a7 = $_POST['PolicyNumber']; } if ($_POST['DeclarationNumber'] == '') { $a8 = '<span style="color:red;">Declaration Number Omitted.</span>'; } else { $a8 = $_POST['DeclarationNumber']; } if ($_POST['InceptionDate'] == '') { $a9 = '<span style="color:red;">Inception Date Omitted.</span>'; } else { $a9 = $_POST['InceptionDate']; } if ($_POST['ExpiryDate'] == '') { $a10 = '<span style="color:red;">Expiry Date Omitted.</span>'; } else { $a10 = $_POST['ExpiryDate']; } if ($_POST['BindingAuthorityNumber'] == '') { $a11 = '<span style="color:red;">Binding Authority Number Omitted.</span>'; } else { $a11 = $_POST['BindingAuthorityNumber']; } if ($_POST['BindingAuthoritySection'] == '') { $a12 = '<span style="color:red;">Binding Authority Section Omitted.</span>'; } else { $a12 = $_POST['BindingAuthoritySection']; } if ($_POST['Coverholder'] == '') { $a13 = '<span style="color:red;">Coverholder Omitted.</span>'; } else { $a13 = $_POST['Coverholder']; } if ($_POST['DateofNotificationfromIsured'] == '') { $a14 = '<span style="color:red;">Date of Notification from Isured Omitted.</span>'; } else { $a14 = $_POST['DateofNotificationfromIsured']; } $message= ' <h1>New Claim Notification</h1> <table cellspacing="1" cellpadding="3" border="2"> <tr> <th><FONT COLOR="#336699">Details Required</font></th> <th><FONT COLOR="#336699">Data entered By Producing Broker or Agent</font></th> <th></th> <th></th> <th><FONT COLOR="#336699">For Administrative Use Only</font></th> </tr> <TR><TD><b><FONT COLOR="#336699">Producing Broker / Agent Name</font></b></TD><TD>'.$a1.'</TD><TD></TD><TD></TD><TD BGCOLOR="#FFFFCC"> </TD></TR> <TR><TD><b><FONT COLOR="#336699">Claims Handler Name</font></b></TD><TD>'.$a2.'</TD><TD></TD><TD></TD><TD BGCOLOR="#FFFFCC"> </TD></TR> <TR><TD><b><FONT COLOR="#336699">Email</font></b></TD><TD>'.$a3.'</TD><TD></TD><TD></TD><TD BGCOLOR="#FFFFCC"> </TD></TR> <TR><TD><b><FONT COLOR="#336699">Contact Number</font></b></TD><TD>'.$a4.'</TD><TD></TD><TD></TD><TD BGCOLOR="#FFFFCC"> </TD></TR> <TR><TD><b><FONT COLOR="#336699">Policyholder</font></b></TD><TD>'.$a5.'</TD><TD></TD><TD></TD><TD BGCOLOR="#FFFFCC"> </TD></TR> <TR><TD><b><FONT COLOR="#336699">Insured Name</font></b></TD><TD>'.$a6.'</TD><TD></TD><TD></TD><TD BGCOLOR="#FFFFCC"> </TD></TR> <TR><TD><b><FONT COLOR="#336699">Policy Number</font></b></TD><TD>'.$a7.'</TD><TD></TD><TD></TD><TD BGCOLOR="#FFFFCC"> </TD></TR> <TR><TD><b><FONT COLOR="#336699">Declaration Number</font></b></TD><TD>'.$a8.'</TD><TD></TD><TD></TD><TD BGCOLOR="#FFFFCC"> </TD></TR> <TR><TD><b><FONT COLOR="#336699">Inception Date</font></b></TD><TD>'.$a9.'</TD><TD></TD><TD></TD><TD BGCOLOR="#FFFFCC"> </TD></TR> <TR><TD><b><FONT COLOR="#336699">Expiry Date</font></b></TD><TD>'.$a10.'</TD><TD></TD><TD></TD><TD BGCOLOR="#FFFFCC"> </TD></TR> <TR><TD><b><FONT COLOR="#336699">Binding Authority Number</font></b></TD><TD>'.$a11.'</TD><TD></TD><TD></TD><TD BGCOLOR="#FFFFCC"> </TD></TR> <TR><TD><b><FONT COLOR="#336699">Binding Authority Section</font></b></TD><TD>'.$a12.'</TD><TD></TD><TD></TD><TD BGCOLOR="#FFFFCC"> </TD></TR> <TR><TD><b><FONT COLOR="#336699">Coverholder</font></b></TD><TD>'.$a13.'</TD><TD></TD><TD></TD><TD BGCOLOR="#FFFFCC"> </TD></TR> <TR><TD><b><FONT COLOR="#336699">Date of Notification from Isured</font></b></TD><TD>'.$a14.'</TD><TD></TD><TD></TD><TD BGCOLOR="#FFFFCC"> </TD></TR> <TR><TD><b><FONT COLOR="#336699">Date of Notification from Isured</font></b></TD><TD>'.$a14.'</TD><TD></TD><TD></TD><TD BGCOLOR="#FFFFCC"> </TD></TR> <TR><TD><b><FONT COLOR="#336699">Date of Notification from Isured</font></b></TD><TD>'.$a14.'</TD><TD></TD><TD></TD><TD BGCOLOR="#FFFFCC"> </TD></TR> <TR><TD colspan="5"></TD></TR> <TR><TD colspan="5"></TD></TR> <TR><TD colspan="5"></TD></TR> <TR><TD colspan="5"></TD></TR> <TR><TD colspan="5"></TD></TR> <TR><TD colspan="5"></TD></TR> <TR><td><b>Claim Receipt Sign Off:</b></TD><td colspan="4"><B>Sign Here:</B></TD></TR> </table> '; // MAIL SUBJECT $subject = "Claims notification Form"; // TO MAIL ADDRESS $to="[email protected]"; /* // MAIL HEADERS $headers = "MIME-Version: 1.0\n"; $headers .= "Content-type: text/html; charset=iso-8859-1\n"; $headers .= "From: '$a3'\r\nReply-To: '$a3'"; */ // MAIL HEADERS with attachment $fp = fopen($strresume, "rb"); $file = fread($fp, $strresume_size); $file = chunk_split(base64_encode($file)); $num = md5(time()); //Normal headers $headers = "From: '$a3'\r\nReply-To: '$a3'"; $headers .= "MIME-Version: 1.0\r\n"; $headers .= "Content-Type: multipart/mixed; "; $headers .= "boundary=".$num."\r\n"; $headers .= "--$num\r\n"; // This two steps to help avoid spam $headers .= "Message-ID: <".$now." TheSystem@".$_SERVER['SERVER_NAME'].">\r\n"; $headers .= "X-Mailer: PHP v".phpversion()."\r\n"; // With message $headers .= "Content-Type: text/html; charset=iso-8859-1\r\n"; $headers .= "Content-Transfer-Encoding: 8bit\r\n"; $headers .= "".$message."\n"; $headers .= "--".$num."\n"; // Attachment headers $headers .= "Content-Type:".$strresume_type." "; $headers .= "name=\"".$strresume_name."\"r\n"; $headers .= "Content-Transfer-Encoding: base64\r\n"; $headers .= "Content-Disposition: attachment; "; $headers .= "filename=\"".$strresume_name."\"\r\n\n"; $headers .= "".$file."\r\n"; $headers .= "--".$num."--"; // SEND MAIL @mail($to, $subject, $message, $headers); fclose($fp); echo ' <h1><B><I><U>New Claim Notification Sent <FONT COLOR=RED>SUCCESSFULLY</FONT></h1></B></I></u> <table cellspacing="5" cellpadding="5" border="2" BORDERCOLOR="#336699"> <tr> <th BGCOLOR="#FFFFCC"><FONT COLOR="#336699">Details Required</font></th> <th BGCOLOR="#FFFFCC"><FONT COLOR="#336699">Data entered By Producing Broker or Agent</font></th> </tr> <TR><TD BGCOLOR="#FFFFCC"><b><FONT COLOR="#336699">Producing Broker / Agent Name</font></b></TD><TD BGCOLOR="#FFFFCC">'.$a1.'</TD></TR> <TR><TD BGCOLOR="#FFFFCC"><b><FONT COLOR="#336699">Claims Handler Name</font></b></TD><TD BGCOLOR="#FFFFCC">'.$a2.'</TD></TR> <TR><TD BGCOLOR="#FFFFCC"><b><FONT COLOR="#336699">Email</font></b></TD><TD BGCOLOR="#FFFFCC">'.$a3.'</TD></TR> <TR><TD BGCOLOR="#FFFFCC"><b><FONT COLOR="#336699">Contact Number</font></b></TD><TD BGCOLOR="#FFFFCC">'.$a4.'</TD></TR> <TR><TD BGCOLOR="#FFFFCC"><b><FONT COLOR="#336699">Policyholder</font></b></TD><TD BGCOLOR="#FFFFCC">'.$a5.'</TD></TR> <TR><TD BGCOLOR="#FFFFCC"><b><FONT COLOR="#336699">Insured Name</font></b></TD><TD BGCOLOR="#FFFFCC">'.$a6.'</TD></TR> <TR><TD BGCOLOR="#FFFFCC"><b><FONT COLOR="#336699">Policy Number</font></b></TD><TD BGCOLOR="#FFFFCC">'.$a7.'</TD></TR> <TR><TD BGCOLOR="#FFFFCC"><b><FONT COLOR="#336699">Declaration Number</font></b></TD><TD BGCOLOR="#FFFFCC">'.$a8.'</TR> <TR><TD BGCOLOR="#FFFFCC"><b><FONT COLOR="#336699">Inception Date</font></b></TD><TD BGCOLOR="#FFFFCC">'.$a9.'</TD></TR> <TR><TD BGCOLOR="#FFFFCC"><b><FONT COLOR="#336699">Expiry Date</font></b></TD><TD BGCOLOR="#FFFFCC">'.$a10.'</TD></TR> <TR><TD BGCOLOR="#FFFFCC"><b><FONT COLOR="#336699">Binding Authority Number</font></b></TD><TD BGCOLOR="#FFFFCC">'.$a11.'</TD></TR> <TR><TD BGCOLOR="#FFFFCC"><b><FONT COLOR="#336699">Binding Authority Section</font></b></TD><TD BGCOLOR="#FFFFCC">'.$a12.'</TD></TR> <TR><TD BGCOLOR="#FFFFCC"><b><FONT COLOR="#336699">Coverholder</font></b></TD><TD BGCOLOR="#FFFFCC">'.$a13.'</TD></TR> <TR><TD BGCOLOR="#FFFFCC"><b><FONT COLOR="#336699">Date of Notification from Isured</font></b></TD><TD BGCOLOR="#FFFFCC">'.$a14.'</TD></TR> </table> <BR> <BR> <B><I>You may wish to print this page for your records the mail has been sent.</b></i> '; ?> ///////////FORM CODE////////////// <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>New Claim Noticication</title> </head> <body bgcolor="#FBFF99"> <h3><u><I>Claims Notification Form</h3></u></i> <table> <form name="frm" method="POST" action="PNC.php" enctype="multipart/form-data"> <tr> <td>Producing Broker / Agent Name - <FONT COLOR="#15009F"><font size=-1><i>Broker Name :</td> <td><input type="text" name="ProducingBroker" size="27"/></td> </tr> <tr> <td>Claims Handler Name - <FONT COLOR="#15009F"><font size=-1><i>Nome :</td> <td><input type="text" name="ClaimsHandlerName" size="27"/></td> </tr> <tr> <td>Email - <FONT COLOR="#15009F"><font size=-1><i>Email :</td> <td><input type="text" name="Email" size="27"/></td> </tr> <tr> <td>Contact Number - <FONT COLOR="#15009F"><font size=-1><i>Telefono :</td> <td><input type="text" name="ContactNo" size="27"/></td> </tr> <tr> <td>Policyholder - <FONT COLOR="#15009F"><font size=-1><i>Contraente :</td> <td><input type="text" name="Policyholder" size="27"/></td> </tr> <tr> <td>Insured Name - <FONT COLOR="#15009F"><font size=-1><i>Nome Assicurato :</td> <td><input type="text" name="InsuredName" size="27"/></td> </tr> <tr> <td>Policy Number - <FONT COLOR="#15009F"><font size=-1><i>Numero Polizzi :</td> <td><input type="text" name="PolicyNumber" size="27"/></td> </tr> <tr> <td>Declaration Number:</td> <td><input type="text" name="DeclarationNumber" size="27"/></td> </tr> <tr> <td>Inception Date - <FONT COLOR="#15009F"><font size=-1><i>Data di Decorrenza :</td> <td><input type="text" name="InceptionDate" size="27"/></td> </tr> <tr> <td>Expiry Date - <FONT COLOR="#15009F"><font size=-1><i>Data di Scadenza :</td> <td><input type="text" name="ExpiryDate" size="27"/></td> </tr> <tr> <td>Binding Authority Number - <FONT COLOR="#15009F"><font size=-1><i>Riferimento Binding Authority :</td> <td><input type="text" name="BindingAuthorityNumber" size="27"/></td> </tr> <tr> <td>Binding Authority Section - <FONT COLOR="#15009F"><font size=-1><i>Sezione Binding Authority :</td> <td><input type="text" name="BindingAuthoritySection" size="27"/></td> </tr> <tr> <td>Coverholder:</td> <td><input type="text" name="Coverholder" size="27"/></td> </tr> <tr> <td>Date of Notification from Isured - <FONT COLOR="#15009F"><font size=-1><i>Data di Notifica ricevuta dall' assicurato :</td> <td><input type="text" name="DateofNotificationfromIsured" size="27"/></td> </tr> <tr> <td>Attach the Policy Document - <FONT COLOR="#15009F"><font size=-1><i>Polizza :</td> <td><input type="File" name="strresume" size="27"/></td> </tr> <tr> <td>Attach the Notification Document - <FONT COLOR="#15009F"><font size=-1><i>Notifica Documenti :</td> <td><input type="file" name="strresume1" size="27"></td> </tr> <tr> <td colspan="3" align="center"> <input type="submit" value="Send Claim Details" name="submit" style="height: 35px; width: 140px; background: #15009F; color:#FFFFFF" onClick="return validate();"> <input type="reset" value="Clear Data" name="reset" style="height: 35px; width: 140px; background: #15009F; color:#FFFFFF"> </td> </tr> </table> </form> </td> </tr> <tr> <td colspan="2" align="center"> </td> </tr> </table> </body> </html> Thanks. Link to comment https://forums.phpfreaks.com/topic/131471-email-with-more-than-one-attachment-problem/ Share on other sites More sharing options...
bobbinsbro Posted November 5, 2008 Share Posted November 5, 2008 ahhhhhhhhhhhh put thr code in code tags please... :-\ Link to comment https://forums.phpfreaks.com/topic/131471-email-with-more-than-one-attachment-problem/#findComment-682780 Share on other sites More sharing options...
redarrow Posted November 5, 2008 Share Posted November 5, 2008 double process ok..... but make sure to fill the second mail function out properly............ <?php //This is email 1 and attachment................... // MAIL SUBJECT $subject = "Claims notification Form"; // TO MAIL ADDRESS $to="[email protected]"; /* // MAIL HEADERS $headers = "MIME-Version: 1.0\n"; $headers .= "Content-type: text/html; charset=iso-8859-1\n"; $headers .= "From: '$a3'\r\nReply-To: '$a3'"; */ // MAIL HEADERS with attachment $fp = fopen($strresume, "rb"); $file = fread($fp, $strresume_size); $file = chunk_split(base64_encode($file)); $num = md5(time()); //Normal headers $headers = "From: '$a3'\r\nReply-To: '$a3'"; $headers .= "MIME-Version: 1.0\r\n"; $headers .= "Content-Type: multipart/mixed; "; $headers .= "boundary=".$num."\r\n"; $headers .= "--$num\r\n"; // This two steps to help avoid spam $headers .= "Message-ID: <".$now." TheSystem@".$_SERVER['SERVER_NAME'].">\r\n"; $headers .= "X-Mailer: PHP v".phpversion()."\r\n"; // With message $headers .= "Content-Type: text/html; charset=iso-8859-1\r\n"; $headers .= "Content-Transfer-Encoding: 8bit\r\n"; $headers .= "".$message."\n"; $headers .= "--".$num."\n"; // Attachment headers $headers .= "Content-Type:".$strresume_type." "; $headers .= "name=\"".$strresume_name."\"r\n"; $headers .= "Content-Transfer-Encoding: base64\r\n"; $headers .= "Content-Disposition: attachment; "; $headers .= "filename=\"".$strresume_name."\"\r\n\n"; $headers .= "".$file."\r\n"; $headers .= "--".$num."--"; // SEND MAIL if(mail($to, $subject, $message, $headers)){ fclose($fp); //This is email 2 and attachment......................... //PLEASE REMEMBER TO FILL CORRECT INFO FOR THIS SENT EMAIL AND ATTACHMENT. // MAIL SUBJECT $subject = "Claims notification Form"; // TO MAIL ADDRESS $to="[email protected]"; /* // MAIL HEADERS $headers = "MIME-Version: 1.0\n"; $headers .= "Content-type: text/html; charset=iso-8859-1\n"; $headers .= "From: '$a3'\r\nReply-To: '$a3'"; */ // MAIL HEADERS with attachment $fp = fopen($strresume, "rb"); $file = fread($fp, $strresume_size); $file = chunk_split(base64_encode($file)); $num = md5(time()); //Normal headers $headers = "From: '$a3'\r\nReply-To: '$a3'"; $headers .= "MIME-Version: 1.0\r\n"; $headers .= "Content-Type: multipart/mixed; "; $headers .= "boundary=".$num."\r\n"; $headers .= "--$num\r\n"; // This two steps to help avoid spam $headers .= "Message-ID: <".$now." TheSystem@".$_SERVER['SERVER_NAME'].">\r\n"; $headers .= "X-Mailer: PHP v".phpversion()."\r\n"; // With message $headers .= "Content-Type: text/html; charset=iso-8859-1\r\n"; $headers .= "Content-Transfer-Encoding: 8bit\r\n"; $headers .= "".$message."\n"; $headers .= "--".$num."\n"; // Attachment headers $headers .= "Content-Type:".$strresume_type." "; $headers .= "name=\"".$strresume_name."\"r\n"; $headers .= "Content-Transfer-Encoding: base64\r\n"; $headers .= "Content-Disposition: attachment; "; $headers .= "filename=\"".$strresume_name."\"\r\n\n"; $headers .= "".$file."\r\n"; $headers .= "--".$num."--"; // SEND MAIL @mail($to, $subject, $message, $headers); fclose($fp); } ?> Link to comment https://forums.phpfreaks.com/topic/131471-email-with-more-than-one-attachment-problem/#findComment-682781 Share on other sites More sharing options...
jimmyh Posted November 5, 2008 Author Share Posted November 5, 2008 Sorry i didnt see the code tag option. Link to comment https://forums.phpfreaks.com/topic/131471-email-with-more-than-one-attachment-problem/#findComment-682782 Share on other sites More sharing options...
jimmyh Posted November 5, 2008 Author Share Posted November 5, 2008 thanks redarrow... however is there a way to put both attachments onto one email rather than have it send 2 different emails? Thanks p.s still cant see how to use Code tags Link to comment https://forums.phpfreaks.com/topic/131471-email-with-more-than-one-attachment-problem/#findComment-682785 Share on other sites More sharing options...
bobbinsbro Posted November 5, 2008 Share Posted November 5, 2008 lol. above the smilies, the button with the sash (#) on. paste code between the tags that appear. Link to comment https://forums.phpfreaks.com/topic/131471-email-with-more-than-one-attachment-problem/#findComment-682788 Share on other sites More sharing options...
redarrow Posted November 5, 2008 Share Posted November 5, 2008 try this only a guess <?php // MAIL SUBJECT $subject = "Claims notification Form"; // TO MAIL ADDRESS $to="[email protected]"; /* // MAIL HEADERS $headers = "MIME-Version: 1.0\n"; $headers .= "Content-type: text/html; charset=iso-8859-1\n"; $headers .= "From: '$a3'\r\nReply-To: '$a3'"; */ // MAIL HEADERS with attachment $fp = fopen($strresume, "rb"); $file = fread($fp, $strresume_size); $file = chunk_split(base64_encode($file)); $num = md5(time()); //Normal headers $headers = "From: '$a3'\r\nReply-To: '$a3'"; $headers .= "MIME-Version: 1.0\r\n"; $headers .= "Content-Type: multipart/mixed; "; $headers .= "boundary=".$num."\r\n"; $headers .= "--$num\r\n"; // This two steps to help avoid spam $headers .= "Message-ID: <".$now." TheSystem@".$_SERVER['SERVER_NAME'].">\r\n"; $headers .= "X-Mailer: PHP v".phpversion()."\r\n"; // With message $headers .= "Content-Type: text/html; charset=iso-8859-1\r\n"; $headers .= "Content-Transfer-Encoding: 8bit\r\n"; $headers .= "".$message."\n"; $headers .= "--".$num."\n"; // Attachment headers $headers .= "Content-Type:".$strresume_type." "; $headers .= "name=\"".$strresume_name."\"r\n"; $headers .= "Content-Transfer-Encoding: base64\r\n"; $headers .= "Content-Disposition: attachment; "; $headers .= "filename=\"".$strresume_name."\"\r\n\n"; $headers .= "".$file."\r\n"; $headers .= "--".$num."--"; // SEND MAIL if(mail($to, $subject, $message, $headers)){ // Attachment headers $headers .= "Content-Type:".$strresume_type." "; $headers .= "name=\"".$strresume_name."\"r\n"; $headers .= "Content-Transfer-Encoding: base64\r\n"; $headers .= "Content-Disposition: attachment; "; $headers .= "filename=\"".$strresume_name."\"\r\n\n"; $headers .= "".$file."\r\n"; $headers .= "--".$num."--"; // SEND MAIL @mail($headers); fclose($fp); } ?> Link to comment https://forums.phpfreaks.com/topic/131471-email-with-more-than-one-attachment-problem/#findComment-682789 Share on other sites More sharing options...
redarrow Posted November 5, 2008 Share Posted November 5, 2008 read this a array way easer sorry http://www.talkphp.com/absolute-beginners/1661-php-mail-help-sending-multiple-attachments.html Link to comment https://forums.phpfreaks.com/topic/131471-email-with-more-than-one-attachment-problem/#findComment-682791 Share on other sites More sharing options...
bobbinsbro Posted November 5, 2008 Share Posted November 5, 2008 a while back someone else wanted to send multiple attachments in the same e-mail. the best thing i managed to find was this free class: http://phpmailer.codeworxtech.com/. in the method detailing page, the attachment methods seem to indicate (in my opinion) that the class can handle multiple attachments. i don't know if this worked, but it might be worth checking out. Link to comment https://forums.phpfreaks.com/topic/131471-email-with-more-than-one-attachment-problem/#findComment-682796 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.