Install and use PhpMailer?

amjavier

Registered
Nov 22, 2017
1
0
1
dubai
cPanel Access Level
Root Administrator
Hi,

I'm very sorry but I'm very newbie in CPanel.
I'm trying to research how can i use the PhpMailer, do i need to install this?
is there a guide how can i install and use PhpMailer?

Thank you very much for any direction you will reply to my query.

Ariel
 

rpvw

Well-Known Member
Jul 18, 2013
1,101
457
113
UK
cPanel Access Level
Root Administrator
Search for phpmailer in YouTube - you will find a number of useful video tutorials.
 

linux4me2

Well-Known Member
Aug 21, 2015
259
76
78
USA
cPanel Access Level
Root Administrator
The big decision is where to install PHPMailer.

If you have a number of accounts on our server that you want to give access to PHPMailer, rather than install it for each account, you can install one instance of PHPMailer in /opt/cpanel/ea-php70/root/usr/share/pear/PHPMailer, or another include path for the primary version of PHP you're running. That way, you can use Composer to keep the single installation of PHPMailer up-to-date, and since it's in the include path, any site that's using that version of PHP can use it.

If you want to offer it for more than one version of PHP, you can add a symlink in the /root/usr/share/pear/ folder corresponding to the version of PHP that points to the actual PHPMailer installation. That way, you only have to maintain one instance of PHPMailer.

Using Composer has been the easiest method of maintaining PHPMailer, though the link at Github will describe both the Composer and non-Composer installs.
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,913
2,205
363
Hello,

The previous posts should help. Let us know if you have additional questions.

Thank you.
 

Ranush

Registered
May 26, 2020
1
0
0
Sri Lanka
cPanel Access Level
Website Owner
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;

require 'PHPMailer/PHPMailer/src/Exception.php';
require 'PHPMailer/PHPMailer/src/PHPMailer.php';
require 'PHPMailer/PHPMailer/src/SMTP.php';

$mail = new PHPMailer;
$mail->isSMTP();
$mail->SMTPDebug = 2;
$mail->Host = 'Outgoing Server ex: sothing.somthing.com does not required mail word before';
//$mail->Debugoutput = 'html';
$mail->Port = 587;
$mail->SMTPSecure = 'tls';

$mail->SMTPAuth = true;
$mail->Username = 'your email ex: something.something.com';
$mail->Password = 'your password of before mentioned email';
$mail->setFrom('before mentioned email', "something");
$mail->addAddress('receive address', "something");
$mail->Subject = 'something';
$mail->msgHTML('something text');
//$mail->msgHTML(file_get_contents('contents.html'), __DIR__);
//Read an HTML message body from an external file, convert referenced images to embedded,
$mail->AltBody = 'HTML messaging not supported';
// $mail->addAttachment('images/phpmailer_mini.png'); //Attach an image file
// echo "err";

if(!$mail->send()){
//echo "Mailer Error: " . $mail->ErrorInfo;
echo "Ok email send";
}else{
echo "err";
}
//$mail->Host = 'please add your cpanel of email server';