$mail = new PHPMailer; $mail->setFrom('from@example.com', 'Your Name'); $mail->addAddress('recipient@example.com', 'Recipient Name'); $mail->Subject = 'Subject of Email'; $mail->isHTML(true); $mail->Body = 'This is the HTML message body'; $mail->AltBody = 'This is the text-only message body'; $mail->send();
$mail = new PHPMailer; $mail->setFrom('from@example.com', 'Your Name'); $mail->addAddress('recipient@example.com', 'Recipient Name'); $mail->Subject = 'Subject of Email'; $mail->isHTML(true); $mail->Body = 'In this example, an attachment is added to the email message, along with the HTML message body. The addAttachment() method is used to specify the file path and name of the attachment. The package library used in these examples is PHPMailer, a popular email sending library for PHP.This is the HTML message body with an attachment
'; $mail->addAttachment('/path/to/file.pdf', 'document.pdf'); $mail->send();