Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>First, in code that you showed as example you have error on this line:</p> <pre><code>$to="admin@admin.com" . "$email"; </code></pre> <p>Change it to:</p> <pre><code>$to="admin@admin.com, " . "$email"; </code></pre> <ul> <li>Notice comma that you are missing... It needed to be there for every new receivers email you want to add on that particular way...</li> </ul> <p>Also I have tested code on my server, everything works well.<br /> I have 100 mbps upload and tried file that is 4.5 MB and it works.</p> <p>So maybe there is a problem with your upload speed and allowed execution time of php script that you are calling to send this email.</p> <p>Try to add the following just after <code>&lt;?php</code> in php file that you setted in HTML form as action="something.php":</p> <pre><code>set_time_limit(0); </code></pre> <p>That means that there is no liimt in execution time of script, change 0 to desired number of seconds...</p> <p>Also remove @ before @mail() function if there are errors you need to see them, hiding them will not do any good for you.</p> <p>EDIT:</p> <p>I have altered your code so that it does check if, firstly if there is file, if not sends mail without attachment. And if there is file it checks if it is encoded to base64 and splited and in that case it send the mail with attachment...</p> <pre><code>&lt;?php $location=$_POST['location']; $name_ha=$_POST['name_ha']; $name_person=$_POST['name_person']; $email=$_POST['email']; $date_sent=$_POST['date_sent']; $date_completed=$_POST['date_completed']; $date_received=$_POST['date_received']; $FilesName = $_FILES["fileAttach"]["name"]; $to = "admin@mail.com," . "$email"; $message = "to"; $sid = md5(uniqid(time())); $header = ""; $header .= "From: ".$_POST["name_ha"]."&lt;".$_POST["email"]."&gt;\nReply-To: ".$_POST["email"].""; $header .= "MIME-Version: 1.0\n"; $header .= "Content-Type: multipart/mixed; boundary=\"".$sid."\"\n\n"; $header .= "This is a multi-part message in MIME format.\n"; $header .= "--".$sid."\n"; $header .= "Content-type: text/html; charset=utf-8\n"; $header .= "Content-Transfer-Encoding: 7bit\n\n"; $header .= $message."\n\n"; if($_FILES["fileAttach"]["name"] != "") { $Content = chunk_split(base64_encode(file_get_contents($_FILES["fileAttach"]["tmp_name"]))); $header .= "--".$sid."\n"; $header .= "Content-Type: application/octet-stream; name=\"".$FilesName."\"\n"; $header .= "Content-Transfer-Encoding: base64\n"; $header .= "Content-Disposition: attachment; filename=\"".$FilesName."\"\n\n"; $header .= $Content."\n\n"; } if (strlen($FilesName) &gt; 0) { if ($Content) { $flgSend = mail($to,"Here is that file",null,$header); } else { echo "problem with file..."; } } else { $flgSend = mail($to,"Here is that file",null,$header); } if ($flgSend) { echo "Mail sent."; } ?&gt; </code></pre> <p><strong>HERE IS HTML FOR IT:</strong></p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;/head&gt; &lt;body&gt; &lt;form method="post" action="sender.php" enctype="multipart/form-data" &gt; location: &lt;input type="text" name="location" /&gt; &lt;br /&gt; name_ha: &lt;input type="text" name="name_ha" /&gt; &lt;br /&gt; name_person: &lt;input type="text" name="name_person" /&gt; &lt;br /&gt; email: &lt;input type="text" name="email" /&gt; &lt;br /&gt; date_sent: &lt;input type="text" name="date_sent" /&gt; &lt;br /&gt; date_completed: &lt;input type="text" name="date_completed" /&gt; &lt;br /&gt; date_received: &lt;input type="text" name="date_received" /&gt; &lt;br /&gt; file: &lt;input type="file" name="fileAttach" /&gt; &lt;br /&gt; &lt;input type="submit" value="submit" /&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
    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.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      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