In websites, We send email to our clients for Following:
- Registration Email
- Forget Password
- Change Password
- Notification Email
- Newsletter
- Order completed
- Order In transist
- Order deliver Successfully
Following code, Which can be used to send email in Zend-Framework (HTML EMAIL).
/** Must fill Following detail * */
$emailTo = 'receipts@no-spam.ws';
$emailToName = 'receipts Name';
/** Must fill Following detail * */
$emailSubject = 'This is subject';
$emailBody = 'This is HTML Email Body';
$fromEmail = 'fromemail@no-spam.ws';
try {
$config = array(
'ssl' => 'tls',
'auth' => 'login',
'username' => 'SMTP_USERNAME',
'password' => 'SMTP_PASSWORD'
);
$transport = new Zend_Mail_Transport_Smtp('SMTP_HOST', $config);
$mail = new Zend_Mail();
$mail->setBodyHtml($emailBody);
$mail->setFrom($fromEmail);
$mail->addTo($emailTo, $emailToName);
$mail->setSubject($emailSubject);
if ($mail->send($transport)) {
echo 'Sent successfully';
} else {
echo 'unable to send email';
}
} catch (Exception $e) {
echo $e->getMessage();
}
Above code is For html email, You can use html tags like
bold, italic, table etc for sending rich text email.