require 'vendor/autoload.php'; $mail = new PHPMailer\PHPMailer\PHPMailer(); $mail->setFrom('from@example.com', 'From Name'); $mail->addAddress('to@example.com', 'To Name'); $mail->Subject = 'Subject'; $mail->Body = 'This is the message body'; if(!$mail->send()) { echo 'Message could not be sent.'; echo 'Mailer Error: ' . $mail->ErrorInfo; } else { echo 'Message has been sent'; }
require 'vendor/autoload.php'; $mail = new PHPMailer\PHPMailer\PHPMailer(); $mail->setFrom('from@example.com', 'From Name'); $mail->addAddress('to@example.com', 'To Name'); $mail->Subject = 'Subject'; $mail->isHTML(true); $mail->Body = 'This is the heading
This is the message body
'; if(!$mail->send()) { echo 'Message could not be sent.'; echo 'Mailer Error: ' . $mail->ErrorInfo; } else { echo 'Message has been sent'; }
require 'vendor/autoload.php'; $mail = new PHPMailer\PHPMailer\PHPMailer(); $mail->setFrom('from@example.com', 'From Name'); $mail->addAddress('to@example.com', 'To Name'); $mail->Subject = 'Subject'; $mail->isHTML(true); $mail->Body = 'Package library: PHPMailer.This is the heading
This is the message body
'; $mail->addAttachment('/path/to/file.pdf', 'pdf_file.pdf'); if(!$mail->send()) { echo 'Message could not be sent.'; echo 'Mailer Error: ' . $mail->ErrorInfo; } else { echo 'Message has been sent'; }