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();
I just need to set $strHeader
variable in JFactory::getMailer();
function I think. please help me?