// require the PHP Contact library require_once('path/to/contact.php'); // create a new instance of the PHP Contact class $contact = new PHPContact(); // set the email address to send the message to $contact->setRecipient('example@example.com'); // set the sender's email address and name $contact->setSender('sender@example.com', 'Sender Name'); // set the message subject and body $contact->setSubject('New Contact Form Submission'); $contact->setMessage('This is a test message.'); // send the email $contact->send();
// require the Swift Mailer library require_once('path/to/swiftmailer/autoload.php'); // create a new Swift Mailer message $message = new Swift_Message(); // set the email address to send the message to $message->setTo('example@example.com'); // set the sender's email address and name $message->setFrom('sender@example.com', 'Sender Name'); // set the message subject and body $message->setSubject('New Contact Form Submission'); $message->setBody('This is a test message.'); // create a new Swift Mailer transport $transport = new Swift_SmtpTransport('smtp.gmail.com', 465, 'ssl'); $transport->setUsername('your_username'); $transport->setPassword('your_password'); // create a new Swift Mailer instance and send the email $mailer = new Swift_Mailer($transport); $mailer->send($message);In this example, we are using the Swift Mailer library to send the email. We create a new message, set the recipient, sender, subject, and message, and create a new transport with our SMTP credentials. Finally, we create a new instance of Swift Mailer and send the email. The package library used in this example is Swift Mailer.