在joomla联系表单中添加代码

时间:2013-12-26 12:31:57

标签: php joomla joomla3.1

请帮帮我我正在尝试在发送邮件中设置附件Joomla v3.1.5我已经设置了所有但未附加邮件的附件。

$strSid = md5(uniqid(time()));

$strHeader = "";
//$strHeader .= "From: ".$_POST["contact_name"]."

<".$_POST["contact_email"].">\nReply-To: ".$_POST["contact_email"]."";

$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";


//*** Attachment ***//

    if($_FILES["filename"]["name"] != "")
{
    $strFilesName = $_FILES["filename"]["name"];
    $strContent = chunk_split(base64_encode(file_get_contents($_FILES["filename"]["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";
}
        // Prepare email body
        $prefix = JText::sprintf('COM_CONTACT_ENQUIRY_TEXT', JUri::base());
        $body   = $prefix."\n".$name.'<'.$email.'>'."\n".$filename."\r\n\r\n".stripslashes($body);

        $mail = JFactory::getMailer();
        $mail->addRecipient($contact->email_to);
        $mail->addReplyTo(array($email, $name));
        $mail->setSender(array($mailfrom, $fromname));
        $mail->setSubject($sitename.': '.$subject);
        $mail->setBody($body);

        $sent = $mail->Send();

我只需要在$strHeader函数中设置JFactory::getMailer();变量。请帮帮我?

1 个答案:

答案 0 :(得分:2)

JED中有许多优秀的高级联系表单扩展,使用其中一个可以为您提供更多灵活性来执行其他操作。如果你想这样做,你应该把它作为一个插件而不是黑客攻击核心文件。此外,您似乎无法扫描可执行扩展程序或检查隐藏在图像文件中的代码。