file attachment mail in php

Maragenie

New Member
hello I am working on html form submission via email. Server side scripting is P H P . my html form is\[code\]<form action='sendmail.php' method='post'> Name:<input type="text" name="name"> File:<input type='file' name='attach'><input type="submit">\[/code\]My php file for sending email is\[code\]<?php $strTo = "[email protected]"; $strHeader .= "From: ".$_POST["name"]."<".$_POST["name"].">"; $strHeader .= "MIME-Version: 1.0\n"; $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"; $strHeader .= $strMessage."\n\n"; if($_FILES["attach"]["name"] != "") { $strFilesName = $_FILES["fileAttach"]["name"]; $strContent = chunk_split(base64_encode(file_get_contents($_FILES["fileAttach"]["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"; } $flgSend = @mail($strTo,"no-subjet",null,$strHeader); \[/code\]but its not going in if condition
 
Back
Top