1. Go to this page and download the library: Download phicorp/mailbox library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
phicorp / mailbox example snippets
use mailBox\mailBox;
// Create an instance of mailBox with SMTP server details.
$mailer = new mailBox('smtp.example.com', 587, 'STARTTLS');
// Set SMTP authentication credentials.
$mailer->auth('your_username', 'your_password');
// Set sender information.
$mailer->setFrom('[email protected]', 'Your Name');
// Set recipient email.
$mailer->to('[email protected]');
// Set email subject and message.
$mailer->subject('Hello, World!');
$mailer->message('This is a test email sent using mailBox class.');
// Optionally, enable HTML email if needed.
// $mailer->isHTML();
// Send the email.
if ($mailer->send()) {
echo "Email sent successfully.";
} else {
echo "Email sending failed.";
}
// Optionally, you can retrieve the logs for debugging purposes.
// $logs = $mailer->getLogs();
use mailBox\mailBox;
// Create an instance of mailBox with SMTP server details.
$mailer = new mailBox('your_smtp_host', 25, 'tls', 'your_username', 'your_password');
// Set sender information.
$mailer->setFrom('[email protected]', 'Your Name');
// Set recipient email.
$mailer->to('[email protected]');
// Set email subject and message.
$mailer->subject('Hello, World!');
$mailer->message('<p>This is a test email sent using mailBox class.</p>');
// Enable HTML mode
$mailer->isHTML();
// Send the email.
$result = $mailer->sendRAW();
if ($result) {
echo "Email sent successfully using default mail() function.";
} else {
echo "Email could not be sent using default mail() function.";
}
mailBox::create('smtp.office365.com', 587)
->encryption('STARTTLS')
->auth('[email protected]', 'your_password')
->setFrom('[email protected]', 'your_name')
->to('[email protected]')
->subject("Hello, World!")
->message("This is a test email sent using mailBox class.")
->send();
mailBox('smtp.gmail.com', 587)
->encryption('STARTTLS')
->auth('[email protected]', 'your_password')
->setFrom('[email protected]', 'your_name')
->to('[email protected]')
->subject("Hello, World!")
->message("<p>This is a test email sent using mailBox class.</p>")->isHTML()
->send();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.