我用一个 html 表单编写了这个 php 脚本,该表单发送通过电子邮件输入的所有数据。如何将其转换为 joomla 3.2.3 的模块?我四处寻找,但不幸的是我没有找到任何东西。
<form action="<?php echo $_SERVER['PHP_SELF'];?>" method="POST" enctype="multipart/form-data">
<table border="0">
<caption align="center"><h3>FORM</h3></caption>
<tr>
<td>Your Mail:</td>
<td><input type="text" name="sender_mail" value="" /></td>
</tr>
<tr>
<td>Name:</td>
<td><input type="text" name="name" value="" /></td>
</tr>
<tr>
<td>Description:</td>
<td><textarea cols="50" rows="10" name="description" style="resize:none"></textarea></td>
</tr>
<tr>
<td>Address:</td>
<td><input type="text" name="address" /></td>
</tr>
<tr>
<td>Image:</td>
<td><input type="file" name="attachFile" /></td>
</tr>
<tr><td><h4>Images:</h4></td></tr>
<tr>
<td><input type="file" name="attachFile1" /></td>
</tr>
<tr>
<td><input type="file" name="attachFile2" /></td>
</tr>
<tr>
<td><input type="file" name="attachFile3" /></td>
</tr>
<tr>
<td><input type="file" name="attachFile4" /></td>
</tr>
<tr>
<td><input type="file" name="attachFile5" /></td>
</tr>
<tr>
<td colspan="2"><input type="submit" name="send" value="send" /></td>
</tr>
</table>
</form>
<?php
if(isset($_POST['send']))
{
$to = "email@example.com";
$subject= "subject";
$todayis = date("l, F j, Y, g:i a") ;
$name = $_POST['name'];
$description = $_POST['description'];
$address = $_POST['address'];
$email = $_POST['sender_mail'];
$message = "
Date: $todayis
Name: $name
description:\n$description\n
address: $address";
$mime_boundary="==Multipart_Boundary_x".md5(mt_rand())."x";
$headers = "From: $email\r\n" .
"MIME-Version: 1.0\r\n" .
"Content-Type: multipart/mixed;\r\n" .
" boundary=\"{$mime_boundary}\"";
$message = "This is a multi-part message in MIME format.\n\n" .
"--{$mime_boundary}\n" .
"Content-Type: text/plain; charset=\"iso-8859-1\"\n" .
"Content-Transfer-Encoding: 7bit\n\n" .
$message . "\n\n";
foreach($_FILES as $userfile)
{
$tmp_name = $userfile['tmp_name'];
$type = $userfile['type'];
$name = $userfile['name'];
$size = $userfile['size'];
if (file_exists($tmp_name))
{
if(is_uploaded_file($tmp_name))
{
$file = fopen($tmp_name,'rb');
$data = fread($file,filesize($tmp_name));
fclose($file);
$data = chunk_split(base64_encode($data));
}
$message .= "--{$mime_boundary}\n" .
"Content-Type: {$type};\n" .
" name=\"{$name}\"\n" .
"Content-Disposition: attachment;\n" .
" filename=\"{$fileatt_name}\"\n" .
"Content-Transfer-Encoding: base64\n\n" .
$data . "\n\n";
}
}
$message.="--{$mime_boundary}--\n";
if (mail($to, $subject, $message, $headers))
echo "Mail sent successfully.";
else
echo "Error in mail";
}
?>
我希望你能帮助我。