1

I'm trying to set up phpMailer. There's no error message, but still, no message is sent. Here's the debug info, retrieved by using PHPMailer::SMTPDebug = 2:

2019-04-04 15:49:57 SERVER -> CLIENT: 220-secure.tourtask.com ESMTP Exim 4.91 #1 Thu, 04 Apr 2019 08:49:57 -0700 220-We do not authorize the use of this system to transport unsolicited, 220 and/or bulk e-mail.
2019-04-04 15:49:57 CLIENT -> SERVER: EHLO eitravel.tourtask.com
2019-04-04 15:49:57 SERVER -> CLIENT: 250-secure.tourtask.com Hello eitravel.tourtask.com [173.231.199.120]250-SIZE 52428800250-8BITMIME250-PIPELINING250-AUTH PLAIN LOGIN250-STARTTLS250 HELP
2019-04-04 15:49:57 CLIENT -> SERVER: STARTTLS
2019-04-04 15:49:57 SERVER -> CLIENT: 220 TLS go ahead
2019-04-04 15:49:57 CLIENT -> SERVER: EHLO eitravel.tourtask.com
2019-04-04 15:49:57 SERVER -> CLIENT: 250-secure.tourtask.com Hello eitravel.tourtask.com [173.231.199.120]250-SIZE 52428800250-8BITMIME250-PIPELINING250-AUTH PLAIN LOGIN250 HELP
2019-04-04 15:49:57 CLIENT -> SERVER: AUTH LOGIN
2019-04-04 15:49:57 SERVER -> CLIENT: 334 VXNlcm5hbWU6
2019-04-04 15:49:57 CLIENT -> SERVER: <credentials hidden>
2019-04-04 15:49:57 SERVER -> CLIENT: 334 UGFzc3dvcmQ6
2019-04-04 15:49:57 CLIENT -> SERVER: <credentials hidden>
2019-04-04 15:49:57 SERVER -> CLIENT: 235 Authentication succeeded
2019-04-04 15:49:57 CLIENT -> SERVER: MAIL FROM:<no-reply@tourtask.com>
2019-04-04 15:49:57 SERVER -> CLIENT: 250 OK
2019-04-04 15:49:57 CLIENT -> SERVER: RCPT TO:<marcus@easterisland.travel>
2019-04-04 15:49:57 SERVER -> CLIENT: 250 Accepted
2019-04-04 15:49:57 CLIENT -> SERVER: DATA
2019-04-04 15:49:57 SERVER -> CLIENT: 354 Enter message, ending with "." on a line by itself
2019-04-04 15:49:57 CLIENT -> SERVER: Date: Thu, 4 Apr 2019 15:49:57 +0000
2019-04-04 15:49:57 CLIENT -> SERVER: To: marcus@easterisland.travel
2019-04-04 15:49:57 CLIENT -> SERVER: From: TourTask <no-reply@tourtask.com>
2019-04-04 15:49:57 CLIENT -> SERVER: Subject: Recover password
2019-04-04 15:49:57 CLIENT -> SERVER: Message-ID: <0b4tAb85GitMRMfogG2IEDSjDXNyL7kQy0g92700@eitravel.tourtask.com>
2019-04-04 15:49:57 CLIENT -> SERVER: X-Mailer: PHPMailer 6.0.7 (https://github.com/PHPMailer/PHPMailer)
2019-04-04 15:49:57 CLIENT -> SERVER: MIME-Version: 1.0
2019-04-04 15:49:57 CLIENT -> SERVER: Content-Type: multipart/alternative;
2019-04-04 15:49:57 CLIENT -> SERVER: boundary="b1_0b4tAb85GitMRMfogG2IEDSjDXNyL7kQy0g92700"
2019-04-04 15:49:57 CLIENT -> SERVER: Content-Transfer-Encoding: 8bit
2019-04-04 15:49:57 CLIENT -> SERVER:
2019-04-04 15:49:57 CLIENT -> SERVER: This is a multi-part message in MIME format.
2019-04-04 15:49:57 CLIENT -> SERVER: --b1_0b4tAb85GitMRMfogG2IEDSjDXNyL7kQy0g92700
2019-04-04 15:49:57 CLIENT -> SERVER: Content-Type: text/plain; charset=us-ascii
2019-04-04 15:49:57 CLIENT -> SERVER:
2019-04-04 15:49:57 CLIENT -> SERVER: This is mail content.
2019-04-04 15:49:57 CLIENT -> SERVER:
2019-04-04 15:49:57 CLIENT -> SERVER: --b1_0b4tAb85GitMRMfogG2IEDSjDXNyL7kQy0g92700
2019-04-04 15:49:57 CLIENT -> SERVER: Content-Type: text/html; charset=us-ascii
2019-04-04 15:49:57 CLIENT -> SERVER:
2019-04-04 15:49:57 CLIENT -> SERVER: <html>This is mail content.</html>
2019-04-04 15:49:57 CLIENT -> SERVER:
2019-04-04 15:49:57 CLIENT -> SERVER:
2019-04-04 15:49:57 CLIENT -> SERVER: --b1_0b4tAb85GitMRMfogG2IEDSjDXNyL7kQy0g92700--
2019-04-04 15:49:57 CLIENT -> SERVER:
2019-04-04 15:49:57 CLIENT -> SERVER: .
2019-04-04 15:49:57 SERVER -> CLIENT: 250 OK id=1hC4cn-0001pn-18
2019-04-04 15:49:57 CLIENT -> SERVER: QUIT
2019-04-04 15:49:57 SERVER -> CLIENT: 221 secure.tourtask.com closing connection

Here's my code:

$sendEmailObj = (object) [
    'toEmail' => $email,
    'subject' => $lang->getStr('Recover_password'),
    'msg' => 'This is mail content.'
];

sendEmail($sendEmailObj);


function sendEmail($emailData) //Skickar mejl
{
    $mail = new PHPMailer(true);

    $mail->CharSet = 'UTF-8';

    $mail->IsSMTP(); //Set mailer to use SMTP
    $mail->SMTPDebug = 2; //Enables SMTP debug information (for testing)

    $mail->Host = 'secure.tourtask.com';  //Specify main and backup server
    $mail->Port = 25;

    $mail->SMTPSecure = 'tls';
    $mail->SMTPAuth = true;     // turn on SMTP authentication
    $mail->Username = 'no-reply@tourtask.com';  // SMTP username
    $mail->Password = 'xxxpass'; // SMTP password

    $mail->setFrom('no-reply@tourtask.com', 'TourTask');

    if (!empty($emailData->fromEmail)) {
        $mail->AddReplyTo($emailData->fromEmail, $emailData->fromName = null);
    }

    $mail->AddAddress($emailData->toEmail, $emailData->toName = null);

    $mail->IsHTML(true); //Set email format to HTML

    $mail->Subject = $emailData->subject;
    $mail->Body    = nl2br('<html>' . $emailData->msg . '</html>');

    if (isset($emailData->msg_plain)) //Message has plain text version
        $mail->AltBody = $emailData->msg_plain;
    else //Has no plain text version - use html version
        $mail->AltBody = $emailData->msg;

    if (!$mail->Send()) {
        $mail->ErrorInfo;
    }
}

What could the problem be? Thanks!

EDIT - Solution

As the post was marked as duplicate, I can't post an answer anymore, but luckily the hosting company did find the solution to this problem.

The problem was that the domain tourtask.com also existed on the receiving host, and the email routing on that host for that domain was set to local. So it was checking it's own server for the email account, when it should have been set to remote. Or just removed from the receiving server if it's not used.

Marcus Edensky
  • 924
  • 3
  • 13
  • 33
  • Looks like it's being sent, from the mail log. Make sure it's not bouncing back, and make sure it's not in the spam folder. – aynber Apr 04 '19 at 16:00
  • I sense there is any error some where. i suggest you change $mail->SMTPDebug value from 2 to 4 so as to see the full error. – ABODE Apr 04 '19 at 16:06
  • 1
    No, setting debug to 4 won't help. The log is showing a successful delivery (and PHPMailer's involvement ends there), so either the message is in your spam folder, or there's a problem with your mail server that will be in the mail server's logs. – Synchro Apr 04 '19 at 16:11

1 Answers1

0

you can try gmail server to check if every thing is working fine. if it is then maybe problem lies in your mail server configuration . NB: make sure your email accept 3rd party apps, you can allow them form settings .

    try {


       $mail->SMTPSecure = 'tls';      
                                  // Set mailer to use SMTP
      $mail->Host = gethostbyname('tls://smtp.gmail.com:587');  // Specify main and backup SMTP servers
      $mail->Port = 587;    
      $mail->SMTPKeepAlive = true;  


    $mail->Username = 'email@gmail.com';              
    $mail->Password = 'passwordgmail';                        
    $mail->isSMTP();                  
    $mail->SMTPAuth = true;                     

    $mail->SMTPOptions = array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
)
);
Shiba Das
  • 350
  • 4
  • 12