-
Notifications
You must be signed in to change notification settings - Fork 0
berry.email.SMTPEMail
Nikos Siatras edited this page Oct 16, 2024
·
2 revisions
public function __construct()
The SMTPEmail class represents a complete email message intended to be sent via direct, from PHP to SMTP server connection, rather than the "traditional" way offered by PHP's mail command. This class was originaly created as a "wrapper" of PHPMailer and is written to always be compatible in future versions even if PHPMailer is replaced.
require_once(__DIR__ . "/berry/email.php"); // Include berry email package
$htmlContent = '<html>';
$htmlContent .= '<body>';
$htmlContent .= '<h1>Email Title</h1>';
$htmlContent .= '<div>Dear customer, this is the server's administrator...</div>';
$htmlContent .= '</body>';
$htmlContent .= '</html>';
$smtpEmail = new SMTPEMail("localhost", 25, "email@domain.com", "password", "");
$smtpEmail->setFrom("admin@domain.com", "Server Administrator");
$smtpEmail->addTo("client@otherdomain.com");
$smtpEmail->setSubject("Email Subject");
$smtpEmail->setHtmlMessage($htmlContent);
// Send the email
if ($smtpEmail ->Send())
{
print "Email sent!";
}
else
{
print "Unable to send the email!";
}
require_once(__DIR__ . "/berry/email.php"); // Include berry email package
$htmlContent = '<html>';
$htmlContent .= '<body>';
$htmlContent .= '<h1>Email Title</h1>';
$htmlContent .= '<div>Dear customer, this is the server's administrator...</div>';
$htmlContent .= '</body>';
$htmlContent .= '</html>';
$smtpEmail = new SMTPEMail("localhost", 587, "email@domain.com", "password", "tls");
$smtpEmail->setFrom("admin@domain.com", "Server Administrator");
$smtpEmail->addTo("client@otherdomain.com");
$smtpEmail->setSubject("Email Subject");
$smtpEmail->setHtmlMessage($htmlContent);
// Send the email
if ($smtpEmail->Send())
{
print "Email sent!";
}
else
{
print "Unable to send the email!";
}