i have use code in php mail send attachment. using apache http server wamp.
<?php $to = 'santosh_091020@rediffmail.com'; // declaring necessary variables mail sending : $subject = 'testing sendmail.exe'; $name = $_request['name'] ; $email = $_request['email'] ; $mob = $_request['mob'] ; $msg = $_request['msg'] ; $message = ' santosh enquire \n\nname: '.$name.' \n email:'. $email.' \n mobile:'. $mob.' \n message: '.$msg.' \n '; // declaration of attributes attachment. $upload_name=$_files["upload"]["name"]; $upload_type=$_files["upload"]["type"]; $upload_size=$_files["upload"]["size"]; $upload_temp=$_files["upload"]["tmp_name"]; $fp = fopen($upload_temp, "rb"); $file = fread($fp, $upload_size); fclose($fp); $file = chunk_split(base64_encode($file)); $num = md5(time()); // defining contents of header. $headers = "from: ".$email. "\r\n" . "cc: santosh@creativecrows.com" ; $headers .= "mime-version: 1.0\r\n"; $headers .= "content-type: multipart/mixed; "; $headers .= "boundary=".$num."\r\n"; $headers .= "--$num\r\n"; //$headers .= "message-id: <".gettimeofday()." thesystem@".$_server['server_name'].">\r\n"; $headers .= "x-mailer: php v".phpversion()."\r\n"; $headers .= "content-type: text/html; charset=iso-8859-1\r\n"; $headers .= "content-transfer-encoding: 8bit\r\n"; $headers .= "".$message."\n"; $headers .= "--".$num."\n"; $headers .= "content-type:".$upload_type." "; $headers .= "name=\"".$upload_name."\"r\n"; $headers .= "content-transfer-encoding: base64\r\n"; $headers .= "content-disposition: attachment; "; $headers .= "filename=\"".$upload_name."\"\r\n\n"; $headers .= "".$file."\r\n"; $headers .= "--".$num."--"; //$data = chunk_split(base64_encode($data)); // sending mail. if(mail($to, $subject, $message, $headers)) { echo "email sent"; send(); } else { echo "email sending failed"; } //send mail in client function send() { $email = $_request['email'] ; $name = $_request['name'] ; $to= trim($email); $subject = 'thanx'; $message = '<html><head><title>html email</title></head> <body style="background-color:#000099;"><p style="color:#000099;">this email contains html tags!</p><table><tr><th>firstname</th><th>lastname</th></tr><tr><td>john</td><td>doe</td></tr></table></body></html>';$headers1 = 'mime-version: 1.0' . "\r\n"; $headers1.= 'content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers1.= "from: ".$email; if(mail($to, $subject, $message,$headers1)) { echo "email sent"; } else { echo "email sending failed"; echo $to; echo $subject; echo $message; } } ?>
but got following error;
delivery following recipient failed permanently: 1.0@localhost technical details of permanent failure: dns error: domain name not found.
please me. thnx in advance.
check url, seems header info not absolute http://webcheatsheet.com/php/send_email_text_html_attachment.php
Comments
Post a Comment