15 replies
My php mail function is only working for gmail...please tell me if you found any error...i need to send email in Hotmail and yahoo as well.

$cemail = trim($_POST['cemail']);
$cname = trim($_POST['cname']);
$subject = "Contact Us";
$message .= "<table><tr><td>Name : </td><td>$cname</td></tr> <tr><td>Email : </td><td>$cemail</td></tr></table>";

$message .= trim($_POST['cmsg']);
$headers = "MIME-Version: 1.0\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\n";
$headers .= "From: $cname<$cemail>" . "\r\n";
$headers .= "X-Mailer: PHP's mail() Function\n";
$to = "abc@hotmail.com";

if(mail($to,$subject,$message,$headers)){
$msgsent = "Thanks for contacting Us";
}
#function #mail #php
  • Profile picture of the author mbaldwin
    They might be marking it as spam,and your mail not getting through at all to hotmail and the like.

    if the mail is being sent, there is nothing wrong with your script. maybe look at using smtp to send the mail through instead of the php mail() function. And send only plain text messages.
    {{ DiscussionBoard.errors[8905135].message }}
    • Profile picture of the author shahriyar
      If the script is sending mail, then the script is working fine, its likely hotmail/yahoo is filtering it or sometimes I found yahoo delivers the email very very late.

      To improve this issue you can check if your Domain's Reverse DNS and MX records set correctly, you can ask your server admin for assistance in this matter.
      {{ DiscussionBoard.errors[8908305].message }}
      • Profile picture of the author Zdenek Koukol
        Originally Posted by shahriyar View Post

        If the script is sending mail, then the script is working fine, its likely hotmail/yahoo is filtering it or sometimes I found yahoo delivers the email very very late.

        To improve this issue you can check if your Domain's Reverse DNS and MX records set correctly, you can ask your server admin for assistance in this matter.
        Yep, I agree with shahriyar
        Signature

        Check my website ... http://www.becomerichforever.com

        {{ DiscussionBoard.errors[8912210].message }}
  • Profile picture of the author mike32
    Talk to your host. Some of them block outgoing email on shared hosting/vps's.
    {{ DiscussionBoard.errors[8917982].message }}
  • Profile picture of the author joekoffi
    I propose stripping off the html headers first, trying simple text. If simple text works, then you'll know where the issue is
    Signature
    Affiliate Marketing For Bloggers, Revealing unknown killer Affiliate Marketing tricks for Bloggers. Special Discount: WF17
    {{ DiscussionBoard.errors[8925050].message }}
    • Profile picture of the author Iconiplex
      Originally Posted by joekoffi View Post

      I propose stripping off the html headers first, trying simple text. If simple text works, then you'll know where the issue is
      Correct answer.

      Code should always be stripped down when facing issues, even if it works sometimes. The HTML you're sending is not proper e-mail HTML, and, combined with your headers, it may be causing issues.

      Of course, it may just be you're e-mails are being blocked, but you need to try basic text e-mails first to see if this is the issue.
      Signature
      US-based design, development, marketing, branding, printing, and all other business services.
      High-risk payment processing for pharma, e-cigs, seeds, and more!
      Accepting investment management clients. Minimum deposit is $3000.
      Skype/AIM: artizhay
      {{ DiscussionBoard.errors[8947935].message }}
  • Profile picture of the author Freescript
    Maybe your host blocked function mail() to yahoo, you can send mail with method SMTP. Here is a lirbrary smtp use to send mail in php, you can use it to send email on your site.
    {{ DiscussionBoard.errors[8947738].message }}
  • Profile picture of the author ineagu
    I would suggest to use an SMTP, there are several ones like : Sendgrid, Mandrill, SendinBluem they are free and their reputation is much higher than your local/shared ip.
    Signature
    SendinBlue.com - Send 350,000 emails / month for $175
    {{ DiscussionBoard.errors[8971344].message }}
  • Profile picture of the author botninja
    If you can, look at the mail log to look for errors - like the others say, rdns etc needs to be spot on to get to Yahoo et all.

    First thing I normally do is log into my VPS (not sure of your set up), and watch the mail queue whilst filling out the form. If you see the mail leaving the server you can then look at the logs etc to see if there are any messages from the far end.
    Signature
    Need something automated? Take a look at The Bot Shop
    {{ DiscussionBoard.errors[8971372].message }}
  • Shoot me a private message I'm happy to help out.
    Signature
    WebDevelopmentGroup NYC & CA- Small Business Web Development, App Development, WordPress Development, Graphic Designs, Online Marketing, Local Marketing & more!. "Call us 1.800.219.1314 or message us!". Visit us today! "Now On Live Chat Mon-Fri.". www.WebDevelopmentGroup.org
    (Whitelable our Services)
    ===================================
    ==> #1 OFFLINE MARKETING FORUM ON THE WEB! <==
    www.OFFLINEMARKETINGFORUM.com
    (Register Now)
    {{ DiscussionBoard.errors[8971885].message }}
  • Profile picture of the author sautaja
    It might be a good idea to set up spf record also. Basically it tells which mail server can send emails on behalf of your domain.
    Signature
    Jomify - Free multi-channel shopping cart. Open your free store now.
    {{ DiscussionBoard.errors[8973542].message }}
  • Profile picture of the author BWHadam
    see if your emails are landing into spam/junk folder. you must add spf for gmail and yahoo. a good practice is to add spf and dkim to send emails. if you don't know about spf and dkim ask your host to add it for you.
    Signature

    Your Slow Website is Killing Your Business!
    Run Your Website like a Ferrari with our FAST VPS in $9/mo

    {{ DiscussionBoard.errors[8973617].message }}
  • {{ DiscussionBoard.errors[9011049].message }}
  • Profile picture of the author Money Coach
    Yes, I also agree with shahriyar.
    {{ DiscussionBoard.errors[9014682].message }}
    • Profile picture of the author huzoorbux
      With mail()? You don't. It blindly shoots the mail out and doesn't handle a lot of possible failure modes. Even then, there's no effective way to capture error output and take appropriate actions.
      Use a mail library that either speaks to your local SMTP server or can invoke sendmail and understand the output enough to verify that the message was accepted for relay. SMTP is vastly preferred here because it's way more verbose when the local relay won't accept the message.
      Signature

      PHP Developer and Founder PHPGang.com Tutorial blog to solve your broblems

      {{ DiscussionBoard.errors[9016222].message }}

Trending Topics