You should avoid this function - it's more verbose, less efficient, more error-prone and
harder to debug than setting properties directly.
Usage Example:
$mail->set('SMTPSecure', 'tls');
is the same as:
$mail->SMTPSecure = 'tls';
isSMTP(); $mail->Host = 'smtp.gmail.com'; $mail->SMTPAuth = true; $mail->Username = 'your.gmail.account@gmail.com'; $mail->Password = 'your_gmail_password'; $mail->SMTPSecure = 'tls'; $mail->Port = 587; $mail->setFrom('your.email@domain.com', 'Your Name'); $mail->addAddress('recipient@hotmail.com', 'Recipient Name'); $mail->Subject = 'Welcome to my website'; $mail->Body = 'Hello! This is a welcome email from my website.'; $mail->send(); ?>
isHTML(true); $mail->setFrom('your.email@domain.com'); $mail->addAddress('recipient@hotmail.com'); $mail->Subject = 'My HTML email'; $mail->Body = 'This example sends an HTML email that includes text and an image. The `isHTML` method is set to `true` to indicate that the `Body` content contains HTML code. The `AltBody` option is used to provide a plain text version of the email for recipients who cannot display HTML emails. PHPMailer is a package library available on Packagist. It can be installed via Composer by running `composer require phpmailer/phpmailer` in your project directory.This is an HTML email
It includes text and an image
'; $mail->AltBody = 'This is the plain text version of the email'; $mail->send(); ?>