php mail attachment fails in wordpress -
i'm using wordpress create site. can me figure out why php mail attachment fails attach files other locations other wordpress folder??? here code :
$subject="enquiry"; $to = "veena@phenomtec.com"; $from = $_post['email']; $url=$_post['resume']; $attachment = chunk_split(base64_encode(file_get_contents($url))); $filename = basename($url); $parts=explode("?",$filename); $filename = $parts[0]; $boundary =md5(date('r', time())); $headers = "from: $from\r\nreply-to: $from"; $headers .= "\r\nmime-version: 1.0\r\ncontent-type: multipart/mixed; boundary=\"_1_$boundary\""; $message="this multi-part message in mime format. --_1_$boundary content-type: multipart/alternative; boundary=\"_2_$boundary\" --_2_$boundary content-type: text/html; charset=\"iso-8859-1\" content-transfer-encoding: 7bit $message --_2_$boundary-- --_1_$boundary content-type: application/octet-stream; name=\"$filename\" content-transfer-encoding: base64 content-disposition: attachment $attachment --_1_$boundary--"; if ( mail($to, $subject, $message, $headers) ){ echo "<script>alert('your email message sent.')</script>"; } else{ echo "<script>alert('sorry, message delivery failed. contact webmaster more info.')</script>"; }
i'm able attach files wordpress folder. i'm unable attach files other locations. please me. in advance.
first of make sure have enctype="multipart/form-data" in form:
<form method="post" enctype="multipart/form-data">
then try code:
$subject="enquiry"; $to = "veena@phenomtec.com"; $from = $_post['email']; $attachment = chunk_split(base64_encode(file_get_contents($_files['resume']['tmp_name']))); $filename = $_files['resume']['name']; $boundary =md5(date('r', time())); $headers = "from: $from\r\nreply-to: $from"; $headers .= "\r\nmime-version: 1.0\r\ncontent-type: multipart/mixed; boundary=\"_1_$boundary\""; $message="this multi-part message in mime format. --_1_$boundary content-type: multipart/alternative; boundary=\"_2_$boundary\" --_2_$boundary content-type: text/html; charset=\"iso-8859-1\" content-transfer-encoding: 7bit $message --_2_$boundary-- --_1_$boundary content-type: application/octet-stream; name=\"$filename\" content-transfer-encoding: base64 content-disposition: attachment $attachment --_1_$boundary--"; if ( mail($to, $subject, $message, $headers) ){ echo "<script>alert('your email message sent.')</script>"; } else{ echo "<script>alert('sorry, message delivery failed. contact webmaster more info.')</script>"; }
hope work :)
Comments
Post a Comment