PC & IT SUPPORT MADE EASY FORUM
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Setting Up PHPMailer On Linux

Go down

Setting Up PHPMailer On Linux Empty Setting Up PHPMailer On Linux

Post by jamied_uk 21st August 2020, 13:05

Vid


Setup:

navigate to /var/www/html folder then run this

Code:
cd /var/www/html


type:

Code:
composer require phpmailer/phpmailer



then goto correct folder

Code:
cd /var/www/html/vendor/phpmailer/phpmailer

type:

Code:
composer require league/oauth2-google



Now to use the script correctly


Usage Notes:
make sure the 2 firsts lines are at the top of document!!


Code:
use PHPMailer\PHPMailer\PHPMailer;
require("../../vendor/autoload.php");
jamied_uk
jamied_uk
Admin

Posts : 2953
Join date : 2010-05-09
Age : 41
Location : UK

https://jnet.sytes.net

Back to top Go down

Setting Up PHPMailer On Linux Empty Re: Setting Up PHPMailer On Linux

Post by jamied_uk 21st August 2020, 13:09

Basic Script


Code:
<?php
ini_set("display_errors", "0");
error_reporting(E_ALL);

use PHPMailer\PHPMailer\PHPMailer;
require("../../vendor/autoload.php"); //Needs to be correct relative to the autoload.php file!
$mail=new PHPMailer;
$mail->isSMTP();
$mail->SMTPDebug=0; // 2 is default
$mail->Host='smtp.gmail.com';
$mail->Port=587;
$mail->SMTPAuth=true;
$mail->Username='email@domain.com';
$mail->Password='password';
$mail->setFrom('email@domain.com', 'JNET');
$mail->addReplyTo('email@domain.com', 'JNET');
$mail->addAddress('email@domain.com', 'Jay');
$mail->Subject='Testing PHPMailer';
//$mail->msgHTML(file_get_contents('message.html'), __DIR__);
$mail->Body='This is a plain text message body';
//$mail->addAttachment('test.txt');
if (!$mail->send()) {
    echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
    echo 'The email message was sent.';
}
?>



For latest scripts for php mailer

alexwebdevelop.com/phpmailer-tutorial
jamied_uk
jamied_uk
Admin

Posts : 2953
Join date : 2010-05-09
Age : 41
Location : UK

https://jnet.sytes.net

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum