错误:警告:mail() [function.mail]:mail() 函数的参数错误,未发送邮件。在 /home/content/19/10977719/html/turgut/email/send.php 第 59 行
我正在尝试发送带有附件的邮件。它显示错误。
它无需附件即可工作,但我不需要它。
这不起作用,同样的错误: http: //www.vivekmoyal.in/send-email-attachment-in-php-send-attachment-in-email-php/
这是我的 php 代码:
$upload_name=$_FILES["upload"]["name"];
$upload_type=$_FILES["upload"]["type"];
$upload_size=$_FILES["upload"]["size"];
$upload_temp=$_FILES["upload"]["tmp_name"];
$fp = fopen($upload_temp, "rb");
$file = fread($fp, $upload_size);
$file = chunk_split(base64_encode($file));
$num = md5(time());
$ad = $_POST['ad'];
$email = $_POST['email'];
$r_email = $_POST['r_email'];
$msg = $_POST['msg'];
$subject = $_POST['konu'];
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: multipart/mixed; ";
$headers .= "boundary=".$num."\r\n";
$headers .= "--$num\r\n";
// spamden kaçmak için bir yöntem
$headers .= "Message-ID: <".gettimeofday()." 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 .= "".$msg."\n";
$headers .= "--".$num."\n";
// Attachment headers
$headers .= "Content-Type:".$upload_type." ";
$headers .= "name=\"".$upload_name."\"r\n";
$headers .= "Content-Transfer-Encoding: base64\r\n";
$headers .= "Content-Disposition: attachment; ";
$headers .= "filename=\"".$upload_name."\"\r\n\n";
$headers .= "".$file."\r\n";
$headers .= "--".$num."--";
$mailsonuc = mail("$r_email","$subject","$msg", $headers);
这是html:
<form id="attach" name="attach" action="gonder.php" method="post" enctype="multipart/form-data">
<h1>{TOP_MSG}</h1>
<table border="0" width="650">
<tr>
<td valign=middle>{NAME}</td>
<td>:</td>
<td><input type="text" placeholder="Adınız Soyadınız" required name="ad" /></td>
</tr>
<tr>
<td valign=middle>{SENDER}</td>
<td>:</td>
<td><input type="text" placeholder="E-Posta Adresiniz" required name="email" /></td>
</tr>
<tr>
<td valign=middle>{RECEIVER}</td>
<td>:</td>
<td><input type="text" placeholder="Alıcı E-Posta Adresi" required name="r_email" /></td>
</tr>
<tr>
<td valign=middle>{KONU}</td>
<td>:</td>
<td><textarea name="konu" required="" cols="46" rows="1"></textarea></td>
</tr>
<tr>
<td valign=middle>{MESSAGE}</td>
<td>:</td>
<td><textarea name="msg" required="" cols="46" rows="7"></textarea></td>
</tr>
<tr>
<td valign=middle>{EK}</td>
<td>:</td>
<td> <input type="file" name="upload" id="upload"></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table>
<div align="center">
<input type="submit" value="Gönder" id="send" name="send" />
</div>
</form>