Note that there are some explanatory texts on larger screens.

plurals
  1. POwhy is my script sending a message to only one recipient in a MYSQL DB
    text
    copied!<p>So i have this code that works perfectly without the 'file attachment' and sends messages typed in a html to all recipients in a MYSQL DB but when i do slot in the attachment codes, the mail gets sent but to only one recipient. Please help me out :)</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;title&gt;test&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;? mysql_connect("localhost", "root", "mypass") or die("Could not connect: " . mysql_error()); mysql_select_db("mydb"); $sql = mysql_query("SELECT * FROM mytable"); while($row = mysql_fetch_array($sql)){ $email = $row["email"]; $strSubject = $_POST["txtSubject"]; $strMessage = nl2br($_POST["txtDescription"]); //*** Uniqid Session ***// $strSid = md5(uniqid(time())); $strHeader = ""; $strHeader .= "From: ".$_POST["txtFormName"]."&lt;".$_POST["txtFormEmail"]."&gt;\nReply-To: ".$_POST["txtFormEmail"].""; $strHeader .= "MIME-Version: 1.0\n"; $strHeader .= "Content-Type: multipart/mixed; boundary=\"".$strSid."\"\n\n"; $strHeader .= "This is a multi-part message in MIME format.\n"; $strHeader .= "--".$strSid."\n"; $strHeader .= "Content-type: text/html; charset=utf-8\n"; $strHeader .= "Content-Transfer-Encoding: 7bit\n\n"; $strHeader .= $strMessage."\n\n"; } //*** Attachment ***// if($_FILES["fileAttach"]["name"] != "") { $strFilesName = $_FILES["fileAttach"]["name"]; $strContent = chunk_split(base64_encode(file_get_contents($_FILES["fileAttach"]["tmp_name"]))); $strHeader .= "--".$strSid."\n"; $strHeader .= "Content-Type: application/octet-stream; name=\"".$strFilesName."\"\n"; $strHeader .= "Content-Transfer-Encoding: base64\n"; $strHeader .= "Content-Disposition: attachment; filename=\"".$strFilesName."\"\n\n"; $strHeader .= $strContent."\n\n"; } $flgSend = @mail($email,$strSubject,null,$strHeader); // @ = No Show Error // if($flgSend) { echo "Task Complete. Your emails are being forwareded to your clients"; } else { echo "Error!!! Task incomplete. Please contact website maintainer."; } ?&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload