I am using this code for HTML mail send:

<?php
        $mailRecepientTo = "em...@test.com";
        $mailRecepientCc = "";
        $mailRecepientBcc = "";
        $mailSenderFrom = "Sitename Team <" . "t...@test.com" . ">";
        $mailSenderReplyTo = "Sitename Team <" . "t...@test.com" . ">";
        
        if ($isDevMachine)
        {
                $mailRecepientTo = "d...@test.com";
                $mailRecepientCc = "";
                $mailRecepientBcc = "";
                $mailSenderFrom = "";
                $mailSenderReplyTo = "";
        }

  ob_start();
  require_once("contact.mail.html");
  $mailBody = ob_get_contents();
  ob_end_clean();

  mail($mailRecepientTo,
       "New Contact Us submission",
       $mailBody,
       ($mailRecepientCc == "" ? "" : "Cc: " . $mailRecepientCc . "\n") .
       ($mailRecepientBcc == "" ? "" : "Bcc: " . $mailRecepientBcc . "\n") .
       ($mailSenderFrom == "" ? "" : "From: " . $mailSenderFrom . "\n") .
       ($mailSenderReplyTo == "" ? "" : "Reply-To: " . $mailSenderReplyTo .
"\n") .
       "X-Mailer: PHP/" . phpversion() . "\n" .
       "MIME-version: 1.0\n" . 
       "Content-type: text/html; charset=us-ascii\n" . 
       "Content-Transfer-Encoding: 8bit\n\n");

?>

-----Original Message-----
From: talk-boun...@lists.nyphp.org [mailto:talk-boun...@lists.nyphp.org] On
Behalf Of justin
Sent: Friday, March 16, 2012 6:17 PM
To: NYPHP Talk
Subject: Re: [nyphp-talk] can't get php to work

I usually use SendGrid (or something similar). Mail/spam/blacklist/etc just
isn't worth dealing with :)

--j


On Fri, Mar 16, 2012 at 8:49 AM, Peter Lehrer <pleh...@gmail.com> wrote:
> OK, Thanks. I installed sendmail on my local machine and got it to 
> work. However, when I send it to my gmail account, it goes into spam.
> This is probably due to the reason Chris enumerated.
>
> Peter
>
> On Fri, Mar 16, 2012 at 11:42 AM, Chris Snyder <chsny...@gmail.com> wrote:
>> On Fri, Mar 16, 2012 at 9:11 AM, Peter Lehrer <pleh...@gmail.com> wrote:
>>> Hi,
>>> I am trying to get the php mail function to work. I have a website 
>>> running Apache2 and PHP Version 5.3.3-7+squeeze8 on Debian. I tried 
>>> to get a test email message working. Here is my code:
>>>
>>> <?php
>>> $to = "pleh...@gmail.com";
>>> $subject = "Test mail";
>>> $message = "Hello! This is a simple email message."; $from = 
>>> "pleh...@me.outlook.com"; $headers = "From:" . $from; 
>>> mail($to,$subject,$message,$headers);
>>> echo "Mail Sent.";
>>> ?>
>>>
>>> Can anybody help me?
>>>
>>
>> Best way to debug mailing issues is to view the mail log and see if 
>> there are any clues as to what went wrong. On Debian, it is at 
>> /var/log/mail.log
>>
>> Very often mail problems have to do with anti-spam controls in 
>> receiving systems. Most big email companies will only accept mail 
>> from servers with a reverse-DNS record that maps the IP address to a 
>> real name. Also, you may be running up against SPF records created by 
>> outlook.com that prevent forging mail from that address.
>>
>> One thing I notice in your script is a missing space after the colon in
"From:".
>> _______________________________________________
>> New York PHP User Group Community Talk Mailing List 
>> http://lists.nyphp.org/mailman/listinfo/talk
>>
>> http://www.nyphp.org/show-participation
> _______________________________________________
> New York PHP User Group Community Talk Mailing List 
> http://lists.nyphp.org/mailman/listinfo/talk
>
> http://www.nyphp.org/show-participation



--
http://justinhileman.com
_______________________________________________
New York PHP User Group Community Talk Mailing List
http://lists.nyphp.org/mailman/listinfo/talk

http://www.nyphp.org/show-participation

_______________________________________________
New York PHP User Group Community Talk Mailing List
http://lists.nyphp.org/mailman/listinfo/talk

http://www.nyphp.org/show-participation

Reply via email to