0

I'm using PHPMailer and my site is hosted on GoDaddy. when I'm sending mail it is saying maile sent but in the mailbox, it is not received. I'm getting the message: Fri, 21 Oct 2022 00:25:38 -0700 220-We do not authorize the use of this system to transport unsolicited, 220 and/or bulk e-mail.

Sometimes on Gmail mail is received but mostly it is not coming also on my domain webmail it is received but on the same mail GSuite it is not received.

below is my code:

Phpmailer_lib.php

<?PHP
    use PHPMailer\PHPMailer\PHPMailer;
    use PHPMailer\PHPMailer\SMTP;
    use PHPMailer\PHPMailer\Exception;

    class PHPMailer_Lib {

        public function __construct() {
            log_message('Debug','PHPMailer class is loaded');
        }

        public function load() {
            require_once APPPATH.'third_party/PHPMailer/src/Exception.php';
            require_once APPPATH.'third_party/PHPMailer/src/PHPMailer.php';
            require_once APPPATH.'third_party/PHPMailer/src/SMTP.php';

            require APPPATH. 'third_party/PHPMailer/src/PHPMailerAutoload.php';

            $mail = new PHPMailer;

            return $mail;
        }
    }

Send mail function

{
    $this->load->library('phpmailer_lib');
    $mail = $this->phpmailer_lib->load();
    
    $mail->SMTPDebug = 2;
    $mail->isSMTP();
    $mail->SMTPAuth   = true;             
    $mail->SMTPSecure = 'ssl';
    $mail->Host       = 'mail.xyz.com';    
    $mail->Port       = 465;    
    $mail->Username   = 'info@xyz.com';
    $mail->Password   = '***';  
            
    $mail->setFrom('info@xyz.com', 'xyz Info');
    $mail->addReplyTo('info@xyz.com', 'xyz Info');

    $mail->addAddress('xyz@gmail.com');
    $mail->addAddress('random@abc.com');
    $mail->addAddress('randon@pqr.com');

    $mail->Subject  = 'PHPMail subject';
    $mail->Body     = '<h5>PHPMail body</h5>';

    $mail->isHTML(true);  

    $mail->ErrorInfo;
    if($mail->send()) {
        echo "Mail sent";
    }else {
        echo "Mail ERROR";
    }
    echo $mail->ErrorInfo;
}
Kumar
  • 1
  • 2
  • That's not an error message, it's just an SMTP "welcome" banner. I suggest you read [the PHPMailer docs on GoDaddy](https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting#godaddy), and learn how to use composer. – Synchro Oct 21 '22 at 09:44
  • ok, but why mails are not received in my Mailbox? am I doing anything wrong? – Kumar Oct 23 '22 at 14:10
  • Check your spam folder, look at the sending transcript with `SMTPDebug = 2` set, and refer to the rest of the troubleshooting guide. – Synchro Oct 23 '22 at 20:42
  • Is it saying mail sent, or is it saying error ? – Rohit Gupta Oct 24 '22 at 04:03
  • it is saying mail sent @RohitGupta – Kumar Oct 29 '22 at 04:57
  • @Synchro already tried there is no mail on spam as well and the status is a success so there is no troubleshooting guide. – Kumar Oct 29 '22 at 04:58
  • But your post talks about an error. It is not clear what is happening. Please edit you question and clarify. – Rohit Gupta Oct 29 '22 at 04:59
  • There are some basic coding errors in your code that will throw warnings. You're also using some strange mixture of current and very old versions of PHPMailer. As I said at the beginning, learn how to use composer, and show us your debug output. – Synchro Oct 30 '22 at 10:45
  • Have updated the question @RohitGupta – Kumar Oct 31 '22 at 09:31

0 Answers0