Developer Snippet Diary

install phpmailer without composer 2023

Download Php mailer from here

https://github.com/PHPMailer/PHPMailer/archive/master.zip

Use below code

<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
use PHPMailer\PHPMailer\SMTP;
require 'PHPMailer/src/Exception.php';
require 'PHPMailer/src/PHPMailer.php';
require 'PHPMailer/src/SMTP.php';
function sendMail($to=null,$subject="test",$message="test"){
$mail = new PHPMailer(true);
    try {
        $mail->SMTPDebug = SMTP::DEBUG_SERVER;                      //Enable verbose debug output
        $mail->isSMTP();                                            //Send using SMTP
        $mail->Host       = 'relay.host.net';                     //Set the SMTP server to send through
        $mail->SMTPAuth   = true;                                   //Enable SMTP authentication
        $mail->Username   = 'usernamehere';                     //SMTP username
        $mail->Password   = 'passwordhere';                               //SMTP password
        $mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS;            //Enable implicit TLS encryption
        $mail->Port       = 465;                                    //TCP port to connect to; use 587 if you have set `SMTPSecure = 
        $mail->setFrom(' noreply@paprikacoin.org', 'paprikacoin.org');
        $mail->addAddress($to);     //Add a recipient
        $mail->isHTML(true);                                  //Set email format to HTML
        $mail->Subject = $subject;
        $mail->Body    = $message;
        $mail->AltBody = $message;

        $mail->send();
        return true;
    } catch (Exception $e) {
        return false;
    }
}
sendMail("rizikmw@gmail.com","testsubject","test message");
Posted by: R GONDAL
Email: rizikmw@gmail.com