9951 explained code solutions for 126 technologies
PHPMailer can be used to send emails without using SMTP by using the mail() function. The mail() function is a built-in PHP function that allows you to send emails directly from a script.
Here is an example of how to use the mail() function with PHPMailer:
<?php // Import the PHPMailer class use PHPMailer\PHPMailer\PHPMailer; // Create a new PHPMailer object $mail = new PHPMailer; // Set the from address $mail->setFrom('[email protected]', 'Sender Name'); // Set the to address $mail->addAddress('[email protected]', 'Receiver Name'); // Set the subject $mail->Subject = 'Test Email'; // Set the body of the email $mail->Body = 'This is a test email!'; // Send the email using the mail() function $mail->send();?>
No output is produced when using the mail() function.
The code above does the following:
For more information on using PHPMailer without SMTP, please see thePHPMailer documentation.