Note that there are some explanatory texts on larger screens.

plurals
  1. POForm email sending with file attachment not sending email nor reporting errors
    primarykey
    data
    text
    <p>I'm trying to send form with file upload , which the user entered, and for some reason it seems not to send the mail. Problem is that I don't get an error to understand where I have a mistake.</p> <p>Before everything, I do not want to use any libraries to do it, I want to keep it simple.</p> <p>Here is the code:</p> <pre><code>&lt;?php if(isset($_POST['Submit'])){ $strTo = "my.email@address.com"; $strSubject = "Purchase request from " . $_POST["formName"] . $_POST["formSurname"]; $strMessage = nl2br($_POST["formName"] . $_POST["formEmail"] . $_POST["formInstitute"] . $_POST["formCourse"] . $_POST["formNotes"]); //*** Uniqid Session ***// $strSid = md5(uniqid(time())); $strHeader = ""; $strHeader .= "From: ".$_POST["formEmail"]."&lt;".$_POST["formEmail"]."&gt;\nReply-To: ".$_POST["formEmail"].""; $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($strTo,$strSubject,null,$strHeader); // @ = No Show Error // if($flgSend) { echo "Mail send completed."; } else { echo "Cannot send mail."; } } ?&gt; </code></pre> <p>and here is the form:</p> <pre><code> &lt;form action="#!/studentform.2ndphase" method="post" name="form1" enctype="multipart/form-data"&gt; &lt;table width="500"&gt; &lt;tr&gt; &lt;td&gt;שם פרטי: &lt;/td&gt; &lt;td&gt;&lt;input name="formName" type="text" id="name"&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;שם משפחה: &lt;/td&gt; &lt;td&gt;&lt;input name="formSurname" type="text" id="surname"&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;דואר אלקטרוני: &lt;/td&gt; &lt;td&gt;&lt;input name="formEmail" type="text"&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;מוסד אקדמי: &lt;/td&gt; &lt;td&gt;&lt;input name="formInstitute" type="text"&gt;&lt;/td&gt; &lt;/tr&gt; &lt;td&gt;מסלול: &lt;/td&gt; &lt;td&gt;&lt;input name="formCourse" type="text"&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;הערות&lt;/td&gt; &lt;td&gt;&lt;textarea name="formNotes" cols="30" rows="4" id="formNotes"&gt;&lt;/textarea&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Attachment&lt;/td&gt; &lt;td&gt;&lt;input name="fileAttach" type="file"&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&amp;nbsp;&lt;/td&gt; &lt;td&gt;&lt;input type="submit" name="Submit" value="שלח"&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/form&gt; </code></pre> <p>The action directs to different page, since I'm using framework based on php, this is why the link is set as <code>#!studentform.2ndphase</code></p> <p>Thanks for any help given.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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