HTML Email sent via PHP treated as spam in Gmail -


i have following php script loads html template .txt file on server , uses str_replace populate template email content before sending email.

at first tried hardcoding webmail address on server 'to' field of mailer_send function worked fine. email template displayed perfectly. however, when tried sending gmail account, marked junk , html displayed plain text. know whether there additional headers need include within email ensure gmail treats correctly?

ideally send email myself via webmail on server , send automated response user thanking them enquiry not possible if message treated spam.

<?php     function mailer_send($mailer_recipient, $mailer_subject, $mailer_message){          $mailer_headers = 'from: webmaster@example' . '\r\n' .         'x-mailer: php/' . phpversion() . '\r\n' .         'mime-version: 1.0\r\n' . '\r\n' .          'content-type: text/html; charset=iso-8859-1\r\n';          mail($mailer_recipient, $mailer_subject, $mailer_message, $mailer_headers);      }  $name = $_post['inputname']; $email = $_post['inputemail']; $message = strip_tags($_post['inputmessage']); $template = file_get_contents('email_templates/template.txt'); $template2 = $template; $template = str_replace('[email_content]',$message, $template);      mailer_send('test@gmail.com','test email',$template);  $message2 = '<h2>thanks..</h2><br/><p>dear' . $name . '</p><br/><p>thanks enquiry. jason quote possible.</p>'; $template2 = str_replace('[email_content]', $message2, $template2); mailer_send($email,'thankyou enquiry',$template2);   ?> 

thanks in advance.

additional:

when email received in gmail appears ignoring header , saying email web hosting providers servers.

theres million reasons why gmail suspect email spam.

the first thing use library deals headers correctly -> http://swiftmailer.org/

secondly, ensure sender host coming same ip server , have correct mx records.


Comments