2

In my website i am using PHPMailer to send automatic mails to the customers. The website is hosted on GoDaddy shared hosting server and using Google Apps as mail service (myserver.com). SPF record is added with myserver.com.

Recently there were many complaints from @hotmail.com, @live.com.au, @live.co.uk, @live.com customers that they are not receiving any mails from the website.

I am using the below code to send mails

Code 1 -- With SMTP

$mail = new PHPMailer;
$mail->isSMTP();
$mail->SMTPDebug = 0;
$mail->Host = 'localhost';
$mail->Port = 25;
$mail->SMTPSecure = 'none';
$mail->SMTPAuth = false;
$mail->setFrom('confirmation@myserver.com', 'Confirmation[My Server]');
$mail->addReplyTo('info@myserver.com', 'My Server');
$mail->addAddress($client_mailid, $client_mailid);
$mail->Subject = $client_mail_sub;
$mail->msgHTML($newbody);

//send the message
if (!$mail->send()) {
    log_entry($mail->ErrorInfo, MAIL_ERR_LOG);
} else {
    log_entry("Mail sent to ". $client_mailid , MAIL_GEN_LOG);
}

I have also tried the below code

Code 2 -- Without SMTP

$mail = new PHPMailer;
$mail->setFrom('confirmation@myserver.com', 'Confirmation[My Server]');
$mail->addReplyTo('info@myserver.com', 'My Server');
$mail->addAddress($client_mailid, $client_mailid);
$mail->Subject = $client_mail_sub;
$mail->Host = "myserver.com";
$mail->msgHTML($newbody);

//send the message
if (!$mail->send()) {
    log_entry($mail->ErrorInfo, MAIL_ERR_LOG);
} else {
    log_entry("Mail sent to ". $client_mailid , MAIL_GEN_LOG);
}

Is there any issue with my codes? If there is no issue what might be the reason for this issue?

I have searched many times to get one solution to the below issue, tried many work arounds and nothing worked for me. I am sorry if this is a repeated question.

Thank you for your help.

EDIT Added the header information

Delivered-To: abc@gmail.com
Received: by 10.96.137.33 with SMTP id qf1csp1412957qdb;
        Wed, 17 Dec 2014 06:47:28 -0800 (PST)
X-Received: by 10.66.124.225 with SMTP id ml1mr5209349pab.142.1418827647092;
        Wed, 17 Dec 2014 06:47:27 -0800 (PST)
Return-Path: <confirmation@myserver.com>
Received: from sg2nlshrout01.shr.prod.sin2.secureserver.net (sg2nlshrout01.shr.prod.sin2.secureserver.net. [182.50.132.193])
        by mx.google.com with ESMTP id it2si5932112pbb.105.2014.12.17.06.47.24;
        Wed, 17 Dec 2014 06:47:26 -0800 (PST)
Received-SPF: pass (google.com: domain of confirmation@myserver.com designates 182.50.132.193 as permitted sender) client-ip=182.50.132.193;
Authentication-Results: mx.google.com;
       spf=pass (google.com: domain of confirmation@myserver.com designates 182.50.132.193 as permitted sender) smtp.mail=confirmation@myserver.com
Received: from sg2nlhg144.shr.prod.sin2.secureserver.net ([182.50.130.216])
    by sg2nlshrout01.shr.prod.sin2.secureserver.net with bizsmtp
    id Uen91p0094gGj8e01en9ff; Wed, 17 Dec 2014 07:47:09 -0700
Received: from www.myserver.com (localhost [127.0.0.1])
    by sg2nlhg144.shr.prod.sin2.secureserver.net (8.14.4/8.12.11) with ESMTP id sBHElOQA024281;
    Wed, 17 Dec 2014 07:47:24 -0700
Date: Wed, 17 Dec 2014 14:47:24 +0000
To: "Confirmation[My Server]" <confirmation@myserver.com>,
        "My Server" <info@myserver.com>
From: "Confirmation[My Server]" <confirmation@myserver.com>
Reply-To: "My Server" <info@myserver.com>
Subject: XXXXXXXXXXXXXXXXXXXXXX.
Message-ID: <209589041f9f422b4a259b3796e90cbc@www.myserver.com>
X-Priority: 3
X-Mailer: PHPMailer 5.2.9 (https://github.com/PHPMailer/PHPMailer/)
MIME-Version: 1.0
Content-Type: multipart/alternative;
    boundary="b1_209589041f9f422b4a259b3796e90cbc"
Content-Transfer-Encoding: 8bit

--b1_209589041f9f422b4a259b3796e90cbc
Content-Type: text/plain; charset=us-ascii

To view the message, please use an HTML compatible email viewer!


--b1_209589041f9f422b4a259b3796e90cbc
Content-Type: text/html; charset=iso-8859-1
Content-Transfer-Encoding: 8bit
fomsn
  • 41
  • 9
  • That's not related of codes. Emails probably fall into junk. – Raptor Dec 12 '14 at 02:15
  • @Raptor it's strange... Normally, the mails are accepted by the destination servers when we use SMTP... – Hilder Vitor Lima Pereira Dec 12 '14 at 02:22
  • @prajilal Does PHPMailer writes something on the log file ? Another question, can you see the mails in your sent box ? – Hilder Vitor Lima Pereira Dec 12 '14 at 02:22
  • 1
    @VitorLima Yes i can see it in the sent box. No error logs are written in the error log file, Success log file has the line "Mail sent to abc@hotmail.com" – fomsn Dec 12 '14 at 02:27
  • @Raptor we have asked all the customers to check their Junk/Spam box. nothing they can see. – fomsn Dec 12 '14 at 02:28
  • are you sending bulk mail? without even reading your code i can tell you 1. there is a limit on outbound php mails from your server (2nd example) 2. all the mail servers listed including gmail will shut you down if you exceed their limits for sending/recieving mail 3. mails that do get through will be spam or at least idendified as bulk. You might consider using amazon ses with a system like phplist to manage flow of emails. – David Dec 12 '14 at 02:49
  • @David i am not sending bulk mails, may be a maximum of 250 mails per day, and those are using different time frames to send the mails. When there is a request from a user my server will send one reply mail to him. Thank you for the other information. At present i cannot migrate to amazon ses due to some other reasons. – fomsn Dec 12 '14 at 02:54
  • try to use `mail()` function to send email (as your SMTP does not require authentication, it will be fine). If still can't, use `telnet` in command prompt / terminal / shell to manual send an email via raw SMTP commands. – Raptor Dec 12 '14 at 02:57
  • 1
    @Raptor thamk you for the reply. I have set mail() function to send the mails, after the test i will post the test results. **Code i used:** $headers = "From: " . $fromMail . "\r\n"; $headers.= "MIME-Version: 1.0\r\n"; $headers.= "Content-Type: text/html; charset=ISO-8859-1\r\n"; mail($to, $subject, $body, $headers); – fomsn Dec 12 '14 at 03:07
  • @Raptor i have tried the solutions. mail() solution didn't work, still the mail didn't reach the destination. shell seems working – fomsn Dec 16 '14 at 00:53
  • That means PHP is using an incorrect SMTP settings. Check `php.ini` – Raptor Dec 16 '14 at 02:33
  • @Raptor thank you, let me try to change. – fomsn Dec 16 '14 at 03:03
  • @Raptor My SMTP settings is as follows SMTP = relay-hosting.secureserver.net Added the header information i can see with the mail sent to Google Mail address. Is this SMTP setting incorrect? – fomsn Dec 18 '14 at 04:19
  • I can't tell. Ask the host. – Raptor Dec 18 '14 at 05:52

0 Answers0