Cartika Support Portal

            SMTP Authentication Failure

            The Mail::factory PHP Script does not like to play well with some of our servers,
            Instruct the client instead to use this one - https://github.com/PHPMailer/PHPMailer

            When sending emails in cPanel, mailer script must utilize smtp authentication and PHP-Pear module or mails will not go out. To verify if Pear module is installed, login to cpanel > PHP PEAR Packages > show system installed modules.
            Then, mailer script can be tailored/modified as per below:

            <?php 
            require_once "Mail.php"; 
            $from = "MyName <name@myemail.com>"; 
            $to = "TargetName <name@targetemail.com>"; 
            $subject = "Hi!"; 
            $body = "Hi,\n\nHow are you?"; 
            $host = "mail.mailserver.com"; 
            $username = "name@myemail.com"; 
            $password = "my_password"; 
            $headers = array ('From' => $from, 
            'To' => $to, 
            'Subject' => $subject); 
            $smtp = Mail::factory('smtp', 
            array ('host' => $host, 
            'auth' => true, 
            'username' => $username, 
            'password' => $password)); 
            $mail = $smtp->send($to, $headers, $body); 
            if (PEAR::isError($mail)) { 
            echo("<p>" . $mail->getMessage() . "</p>"); 
            } else { 
            echo("<p>Message successfully sent!</p>"); 

            ?>
            Updated: 24 Jun 2018 01:37 PM
            Helpful?  
            Help us to make this article better
            0 0