php - Email with attachments going to Spam folder - VPS Server -


i'm trying fix issue. email attachments going spam folder. came across similar issues & html email.but here attachment. if did not add "from" in header email coming inbox (username@vps.mydomain.com). i'm tying change sender email wont go spam. have managed change "from" in header still goes spam.

also tried "-f" concept, still goes spam.

here headers & message attachment

$header .= "mime-version: 1.0\r\n";   //$header .= 'from: move <info@ccc.com>' . "\r\n";   //$header .= "reply-to: ".$replyto."\r\n"; $header .= "content-type: multipart/mixed; boundary=\"".$uid."\"\r\n\r\n"; $message = "this multi-part message in mime format.\r\n\r\n"; $message .= "--".$uid."\r\n"; $message .= "content-type:text/html; charset=iso-8859-1\r\n";   $message .= "content-transfer-encoding: 7bit\r\n\r\n"; $message .= $emailtext."\r\n\r\n"; $message .= "--".$uid."\r\n"; $message .= "content-type: application/pdf; name=\"".$filename."\"\r\n"; $message .= "content-transfer-encoding: base64\r\n"; $message .= "content-disposition: attachment; filename=\"".$filename."\"\r\n\r\n";     $message .= $content."\r\n\r\n"; $message .= "--".$uid."--";     if (mail($email, $subject, $message, $header, "-finfo@ccc.com")) { 

edit #2: (pdf attachment)

you need enter $_post variables, if try is, including pdf file wish send, run on own. change instances of file.pdf in code file name wish attach, email address. (tested)

<?php $sendto = "email@example.com"; $message = "message here\r\n hello, test!!";  $filename = "file.pdf"; $handle = fopen($filename, 'rb'); $contents = fread($handle,filesize($filename)); fclose($handle); $encoded = chunk_split(base64_encode($contents));  $seperator = md5(uniqid(time())); $from = '"first last" <username@domain.com>'; $header = ''; $header .= "from: $from\r\n"; $header .= "mime-version: 1.0\r\ncontent-type:"." multipart/mixed; boundary=\"$seperator\";\r\n";   $body.= "--$seperator\r\n"; $body.= "content-type: text/plain; charset=\"iso-8859-1\"\r\n"; $body.= "content-transfer-encoding: 7bit\r\n\n"; $body.= $message."\r\n\n";  $body.= "--$seperator\r\n"; $body.= "content-type: application/pdf; name=\"file.pdf\"\r\n"; $body.= "content-transfer-encoding: base64\r\n"; $body.= "content-disposition: attachment; filename=\"file.pdf\"\r\n\n"; $body.= $encoded."\r\n"; $body.= "--$seperator--\r\n";  mail($sendto,$subject, $body, $header); ?>  

Comments

Popular posts from this blog

assembly - 8086 TASM: Illegal Indexing Mode -

Java, LWJGL, OpenGL 1.1, decoding BufferedImage to Bytebuffer and binding to OpenGL across classes -

javascript - addthis share facebook and google+ url -