0

Following given the code

$this->load->library("phpmailer_library");
$mail = $this->phpmailer_library->load();
                          // Passing `true` enables exceptions
echo "started<br>";
try {
    //Server settings

    $mail->isSMTP();    // Set mailer to use SMTP
    $mail->SMTPDebug = 1;         // Enable verbose debug output    
    $mail->SMTPAuth = true;                               // Enable SMTP authentication     
    $mail->SMTPSecure = 'ssl';                            // Enable TLS encryption, `ssl` also accepted                   
    $mail->Host = 'smtp.gmail.com';  // Specify main and backup SMTP servers
    $mail->Port = 465;                                    // TCP port to connect to
    $mail->isHTML(true);                                  // Set email format to HTML
    $mail->Username = '****';                 // SMTP username
    $mail->Password = '*****';                           // SMTP password


    echo "Oject is working<br>";    
    //Recipients
    $mail->setFrom('dhawal.b@itransparity.com', 'Mailer');
    $mail->addAddress('dhawalbhatt21@gmail.com', 'Dhawal Bhatt');     // Add a recipient
                // Name is optional
    echo "Set the From and To <br>";
    $mail->addReplyTo('dhawal.b@itransparity.com', 'Information');
    $mail->addCC('dhawalbhatt21@gmail.com');
    $mail->addBCC('dhawalbhatt21@gmail.com');
    echo "Set the reply to and CC and BCC <br>";
    //Attachments
    $mail->addAttachment('C:/xampp/htdocs/welnext_product2/files/list_of_cases.csv','list_of_cases');         // Add attachments

    echo "Attachment config is working<br>";
    //Content

    $mail->Subject = 'Here is the subject';
    $mail->Body    = 'This is the HTML message body <b>in bold!</b>';
    $mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
    echo "Email config is working<br>";
    $mail->send();
    echo 'Message has been sent<br>';
} catch (Exception $e) {
    echo 'Message could not be sent. Mailer Error: ', $mail->ErrorInfo;
}
Synchro
  • 35,538
  • 15
  • 81
  • 104
  • There's not enough info here. It looks like you're using an old version of PHPMailer, you've not read [the PHPMailer troubleshooting guide](https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting), and I'd guess you've not searched for similar questions on here either. – Synchro Dec 20 '18 at 08:51
  • Possible duplicate of [SMTP connect() failed PHPmailer - PHP](https://stackoverflow.com/questions/22927634/smtp-connect-failed-phpmailer-php) – Synchro Dec 20 '18 at 08:52
  • thank you, I have just config the XAMPP server before the send mail, that reason it not working. – Dhawal Bhatt Dec 20 '18 at 10:26
  • Then I suggest you close this question as it won't help anyone else. – Synchro Dec 20 '18 at 15:51
  • How to close the question ??? – Dhawal Bhatt Dec 21 '18 at 08:13

0 Answers0