composer require phpmailer/phpmailer
github
Minimales Beispiel
Imports
Mit Composer
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
require_once('path/to/vendor/autoload.php');
Manuel
require_once('path/to/phpmailer/src/PHPMailer.php');
require_once('path/to/phpmailer/src/SMTP.php'); // if needed
require_once('path/to/phpmailer/src/Exceptions.php'); // if needed
Befehle
$mail = new PHPMailer(TRUE);
try {
$mail->setFrom(from@email.org','Ich bin ich');
$mail->addAddress('to@email.org');
$mail->Subject = 'E-Mail test;
$mail->Body = 'This is your message;
$mail->isSMTP();
$mail->Host = 'gothicus.metanet.ch';
$mail->SMTPAuth = TRUE;
$mail->SMTPSecure = 'tls';
$mail->Username = 'noreply@toolcase.org';
$mail->Password = '* SECURE *';
$mail->Port = 587;
$mail->send();
}
catch (Exception $e) { echo $e->errorMessage(); } // PHPMailer Exceptionx
catch (\Exception $e) { echo $e->getMessage(); } // PHP Exceptions