Skip to content

berry.email.SMTPEMail

Nikos Siatras edited this page Oct 16, 2024 · 2 revisions

Description

 public function __construct()

SMTPEMail class represents a simple e-mail message that will be sent out using an SMTP Server

Example for SMTP with plain text authentication

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>';

$mail = new SMTPEMail("localhost", 25, "email@domain.com", "password", "");
$mail->setFrom("admin@domain.com", "Server Administrator");
$mail->addTo("client@otherdomain.com");
$mail->setSubject("Email Subject");
$mail->setHtmlMessage($htmlContent);

// Send the email
if ($email->Send())
{
    print "Email sent!";
}
else
{
    print "Unable to send the email!";
}

Example for SMTP with TLS Encryption authentication

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>';

$mail = new SMTPEMail("localhost", 587, "email@domain.com", "password", "tls");
$mail->setFrom("admin@domain.com", "Server Administrator");
$mail->addTo("client@otherdomain.com");
$mail->setSubject("Email Subject");
$mail->setHtmlMessage($htmlContent);

// Send the email
if ($email->Send())
{
    print "Email sent!";
}
else
{
    print "Unable to send the email!";
}
Clone this wiki locally