SMTPDebug = 0; // Enable verbose debug output $mail->isSMTP(); // Send using SMTP $mail->Host = 'smtp.gmail.com'; // Set the SMTP server to send through $mail->SMTPAuth = true; // Enable SMTP authentication $mail->Username = 'yourname@gmail.com'; // SMTP username $mail->Password = 'yourpassword'; // SMTP password $mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS; // Enable TLS encryption; `PHPMailer::ENCRYPTION_SMTPS` encouraged $mail->Port = 587; // TCP port to connect to, use 465 for `PHPMailer::ENCRYPTION_SMTPS` above // Recipients $mail->setFrom('from@example.com', 'Mailer'); $mail->addAddress('johndoe@example.com', 'John Doe'); // Add a recipient // Content $mail->isHTML(true); // Set email format to HTML $mail->Subject = 'Here is the subject'; $mail->Body = 'This is the HTML message body in bold!'; $mail->AltBody = 'This is the body in plain text for non-HTML mail clients'; $mail->send(); echo 'Message has been sent'; } catch (Exception $e) { echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}"; } ?>
isSMTP(); // Send using SMTP $mail->Host = 'smtp.gmail.com'; // Set the SMTP server to send through $mail->SMTPAuth = true; // Enable SMTP authentication $mail->Username = 'yourname@gmail.com'; // SMTP username $mail->Password = 'yourpassword'; // SMTP password $mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS; // Enable TLS encryption; `PHPMailer::ENCRYPTION_SMTPS` encouraged $mail->Port = 587; // TCP port to connect to, use 465 for `PHPMailer::ENCRYPTION_SMTPS` above // Recipients $mail->setFrom('from@example.com', 'Mailer'); $mail->addAddress('johndoe@example.com', 'John Doe'); // Add a recipient // Content $mail->isHTML(true); // Set email format to HTML $mail->Subject = 'Here is the subject'; $mail->Body = file_get_contents('path/to/your/custom/template.html'); $mail->AltBody = 'This is the body in plain text for non-HTML mail clients'; $mail->send(); echo 'Message has been sent'; } catch (Exception $e) { echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}"; } ?>This example demonstrates how to create and send a custom email using PHP Email Factory. The email content is loaded from an external HTML file, allowing for more advanced layouts and styling. Overall, PHP Email Factory is a powerful and flexible package library that provides developers with everything they need to create and send emails using PHP. Its intuitive interface and extensive range of features make it a popular choice for developers and businesses alike.