在joomla联系表单中添加代码 [英] add code in joomla contact form

查看:134
本文介绍了在joomla联系表单中添加代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请帮助我,我正在尝试设置发送邮件中的附件Joomla v3.1.5我已设置了所有但邮件中没有接收到的附件.

Please Help me I am trying to setup attached file in send mail Joomla v3.1.5 I have set all but attached file not receiving in mail.

$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();

我只需要在我认为的JFactory::getMailer();函数中设置$strHeader变量即可.请帮帮我吗?

I just need to set $strHeader variable in JFactory::getMailer(); function I think. please help me?

推荐答案

JED中有许多很好的高级联系表单扩展,使用其中一种将为您提供更多的灵活性来执行其他操作.仍然,如果要执行此操作,则应将其作为插件执行,而不要修改核心文件.另外,您似乎并没有在扫描可执行扩展名,也没有在检查图像文件中隐藏的代码.

There are so many good advanced contact form extensions in the JED, using one of those is going to give you so much more flexibility to do additional things. Still if you want to do this, you should do it as a plugin rather than hacking core files. Also, you don't seem to be scanning for executable extensions or to be checking for code hidden in image files.

这篇关于在joomla联系表单中添加代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆