Viewed   72 times

Here are my codes for sending mail:

    $fullname = $_POST['fullname'];
    $email = $_POST['email'];
    $telephone = $_POST['telephone'];
    $email = $_POST['email'];
    $date = $_POST['date'];
    $time = $_POST['time'];
    $adult = $_POST['adult'];
    $children = $_POST['children'];
    $company_name = $_POST['company_name'];
    $addition = $_POST['addition'];
    $confirm = $_POST['confirm'];

    $body = '
    <table width="100%" border="0" cellpadding="0">
      <tr>
        <td>Dear Sir,
        </td>
      </tr>
      <tr>
        <td><b>Booking request from '.$fullname .'</b><br /><br />
          <u>The details provided are:</u><br />
          <p>Name : '.$fullname.'<br />
          E-mail Address: '.$email.'<br />
          Telephone: '.$telephone.'<br />
          Date: '.$date.'<br />
          Time: '.$time.'<br />
          Adult: '.$adult.'<br />
          Children: '.$children.'<br />
          Company Name: '.$company_name.'<br />
           Confirm by: '.$confirm .'<br />
         Additional Requirements: '.$addition.'<br />
          </p>
           </td>
      </tr>
      <tr>
        <td>
        <p>Thank you,<br />
        Kaavya Cuisine
        </p></td>
      </tr>
    </table>
    ';

    $to         = 'sujal@longtail.info';
    $subject    = 'Booking Request';
    $sitename='Website Name';

    $mail = new PHPMailer(); 
    $mail->AddReplyTo($to,$sitename);
    $mail->SetFrom($email,$fullname);


    $mail->AddAddress($to, $sitename);
    $mail->Subject    = $subject;

    $mail->MsgHTML($body);
    $mail->Send();

Every time I send the mail, it goes in to spam. Does anyone know why this is happening?

 Answers

4

Based on you code i notice that you are sending an email directly from you web page on your domain.

For example you used an @hotmail.com address.

When the recipient receive the emails the mail service of the recipient may test a reverse DNS of the sender of the mail. So the sender is from @hotmail.com but the mail comes from your domain which of course is not hotmail.com.

So I receive a mail from an address @hotmail.com but the IP sender isn't related at all with domain hotmail.com: that's SPAM!

http://en.wikipedia.org/wiki/Reverse_DNS_lookup

I think a possible solution is: in you PHP code use authenticate with SMTP and from there send the mail!

Tuesday, November 1, 2022
1

Solution: Use Mailgun (not tested) or Sendgrid (tested and works wonders!). There is a price-difference between the two, - but in short: Mailgun is good if you're small; Sendgrid is good if you're big.

Either that, - or send mails using MailChimps API or something. It's can't be fixed on shared hosts (most likely). The reason is below.


Explanation: I've later learned more about how shared hosts work. Imagine that several different sites are located on the same server (such as domain-1.org, domain-2.org and domain-3.org). That means that if domain-3.org sends a bunch of crap-emails, then Gmail (and other spam-filters) mark that IP-address as spam. So if domain-2.org then send out stuff, then that'll (probably) come from the some IP-address and therefore end up in spam. Shared hosts can't really do anything about it (and don't care, since so few people have this problem). And that is why it's so cheap.

Sendgrid and Mailguns IP-addresses are marked as 'fine' by all the spam-filters, and that's the service that you're paying for with them. They keep it that way, by monitoring how many emails you send out are being marked as 'spam'. If it's something like 5%-10% or something crazy low, then Sendgrid/Mailgun will block your account until you fix it (going through a long process, where you have to contact their customer service and do 1.000 hail-Mary's and all kinds of wierd stuff).

I heard that if you get your own server (which is way more expensive), and set up your own mail-server, then you have to be really careful, not to be marked as spam. Cause spam-filter are really tough nowadays...

Friday, December 23, 2022
5

After trying various ways, i found following code working with almost all email providers

$to['email'] = "recipients email address";      
$to['name'] = "name";   
$subject = "email subject";
$str = "<p>Hello, World</p>";
$mail = new PHPMailer;
$mail->IsSMTP();                                     
$mail->SMTPAuth = true;
$mail->Host = 'Specify main and backup server here';
$mail->Port = 465;
$mail->Username = 'xyz@domainname.com';
$mail->Password = 'email account password';
$mail->SMTPSecure = 'ssl';
$mail->From = 'From Email Address';
$mail->FromName = "Any Name";
$mail->AddReplyTo('xyz@domainname.com', 'any name'); 
$mail->AddAddress($to['email'],$to['name']);
$mail->Priority = 1;
$mail->AddCustomHeader("X-MSMail-Priority: High");
$mail->WordWrap = 50;    
$mail->IsHTML(true);  
$mail->Subject = $subject;
$mail->Body    = $str;
if(!$mail->Send()) {
$err = 'Message could not be sent.';
$err .= 'Mailer Error: ' . $mail->ErrorInfo;                        
}

$mail->ClearAddresses();

variable values needs to be changed accordingly. Hope these helps people having issues with PHPmailer

Saturday, November 19, 2022
 
3

The problem is simple that the PHP-Mail function is not using a well configured SMTP Server.

Nowadays Email-Clients and Servers perform massive checks on the emails sending server, like Reverse-DNS-Lookups, Graylisting and whatevs. All this tests will fail with the php mail() function. If you are using a dynamic ip, its even worse.

Use the PHPMailer-Class and configure it to use smtp-auth along with a well configured, dedicated SMTP Server (either a local one, or a remote one) and your problems are gone.

https://github.com/PHPMailer/PHPMailer

Saturday, December 24, 2022
 
4

Your vps doesn't have rDNS configured and the HELO points to a different ip. inconsistencies in HELO and missing rDNS trigger many spamfilters.

Received: from ryanteck.org.uk ([95.154.250.75])

Host 75.250.154.95.in-addr.arpa. not found: 3(NXDOMAIN)

ryanteck.org.uk has address 95.154.250.165

Set a HELO Hostname whose A-Record points back to your VPS and configure the rDNS (PTR) to the same hostname.

Example:

  • Create a new A-Record 'vps.ryanteck.org.uk 95.154.250.75'
  • Set the HELO to 'vps.ryanteck.org.uk'
  • Set the reverse DNS (PTR) for 75.250.154.95 to vps.ryanteck.org.uk

Also your senderdomains have somewhat strange "TXT" records:

dig txt mc-serverlist.co.uk +short 
"95.154.250.165"
dig txt ryanteck.org.uk +short
"95.154.250.165"

you may want to change these into correctly formatted SPF records, eg.

v=spf1 ip4:95.154.250.165 ip4:95.154.250.75 ~all
Friday, August 19, 2022
 
Only authorized users can answer the search term. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :