message sent to mail go to spam mail

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • simon2x1
    New Member
    • Dec 2008
    • 123

    message sent to mail go to spam mail

    the code below is my mail code its working but message sent to the email is going to the spam mail not the inbox how can make the message go to indox

    Code:
    <?php
    require_once("connect.php");
    
    // value sent from form
    $email_to=$_POST['email_to'];
    
    // table name
    $tbl_name=members;
    
    // retrieve password from table where e-mail = $email_to(mark@phpeasystep.com)
    $sql="SELECT password FROM $tbl_name WHERE email='$email_to'";
    $result=mysql_query($sql);
    
    // if found this e-mail address, row must be 1 row
    // keep value in variable name "$count"
    $count=mysql_num_rows($result);
    
    // compare if $count =1 row
    if($count==1){
    
    $rows=mysql_fetch_array($result);
    
    // keep password in $your_password
    $your_password=$rows['password'];
    
    // ---------------- SEND MAIL FORM ----------------
    
    // send e-mail to ...
    $to=$email_to;
    
    // Your subject
    $subject="Your password here";
    
    // From
    $header="from: your name <your email>";
    
    // Your message
    $messages= "Your password for login to our website \r\n";
    $messages.="Your password is $your_password \r\n";
    $messages.="more message... \r\n";
    
    // send email
    $sentmail = mail($to,$subject,$messages,$header);
    
    }
    
    // else if $count not equal 1
    else {
    echo "Not found your email in our database";
    }
    
    // if your email succesfully sent
    if($sentmail){
    echo "Your Password Has Been Sent To Your Email Address.";
    }
    else {
    echo "Cannot send password to your e-mail address";
    }
    
    ?>
  • dlite922
    Recognized Expert Top Contributor
    • Dec 2007
    • 1586

    #2
    I don't even need to look at your code. This is not a code problem. It is beyond your control, to a certain point.

    If you domain is new, and doesn't have an SPF record, add one now (ask your provider, google it).
    2. Make sure you have a valid "FROM" record. Most likely If this field is empty you won't even see it in any folder, mailservers automatically reject it.

    Ask the mail service (yahoo, hotmail, aol, the company) to put you on the white list.

    It will take some time and patience. Until then, avoid putting any images or HTML in the events.



    Dan

    Comment

    • hsriat
      Recognized Expert Top Contributor
      • Jan 2008
      • 1653

      #3
      Verify that the MX and A records of your domain DNS configuration are set to the IP of the server from whom you are sending the mail.
      (SPF - as Dan said)

      Comment

      • simon2x1
        New Member
        • Dec 2008
        • 123

        #4
        please can you explain further or i you saying i should add my smtp setting to the mail function if so how can i do that can give me an example

        Comment

        • labmonkey111
          New Member
          • Sep 2008
          • 44

          #5
          Including the X-Mailer and Message-ID headers can also help in avoiding getting tagged as spam. I had the same problem, drove me nuts until I figured this out.

          Comment

          • zorgi
            Recognized Expert Contributor
            • Mar 2008
            • 431

            #6
            Or you can simply use PHPMailer and forget about how its done. I used it in the past and am very pleased with results. :

            Actu tech, cybersécurité, e-commerce, culture web : PHPMailer Magazine explore les sujets qui façonnent le numérique. Un regard indépendant sur l’univers digital.

            Comment

            • simon2x1
              New Member
              • Dec 2008
              • 123

              #7
              i have a problem my mail functiom

              the code below was a code give to me to solve me to stop my mail from going in to spam but i have a problem with line 16 how can i fix and what should i do i will appreciate if u will edit the problem on the code below

              Code:
              <?php
              include("Mail.php");
              /* mail setup recipients, subject etc */
              $recipients = "feedback@yourdot.com";
              $headers["From"] = "user@somewhere.com";
              $headers["To"] = "feedback@yourdot.com";
              $headers["Subject"] = "User feedback";
              $mailmsg = "Hello, This is a test.";
              /* SMTP server name, port, user/passwd */
              $smtpinfo["host"] = "smtp.mycorp.com";
              $smtpinfo["port"] = "25";
              $smtpinfo["auth"] = true;
              $smtpinfo["username"] = "smtpusername";
              $smtpinfo["password"] = "smtpPassword";
              /* Create the mail object using the Mail::factory method */
              $mail_object =& Mail::factory("smtp", $smtpinfo);
              /* Ok send mail */
              $mail_object->send($recipients, $headers, $mailmsg);

              Comment

              Working...