Dot_Email class extends Zend_Mail, so all the methods from Zend_Mail are available in Dot_Email.
Dot_Email is a simple class composed only from 2 methods, except constructor, all other methods beeing inherited from Zend_Mail.
1. setContent() , as the name is suggesting, set the body of the email by calling setBodyText() (if format is “text/plain”) or setBodyHtml() (if format is “text/html”).
Note the declaration of this method: setContent ($content, $format = ‘text/plain’)
2. send(), set the transporter and is calling parent::send() method for sending the email
For sending the email you MUST use this methods in the code above:
$dotEmail = new Dot_Email();
$dotEmail->addTo($email);
$dotEmail->setSubject('Forgot Password');
$dotEmail->setBodyText('Your password is '.$password);
$succeed = $dotEmail->send();
if($succeed)
{
echo "Message sent!";
}
else
{
echo "Message failed, not sent!";
}
Only if you want to overwrite the default Email and Name, add the below lines:
$dotEmail->setFrom($fromEmail, $fromName);
$dotEmail->setReplyTo($fromEmail, $fromName);
NOTE*: you always have to use addTo(), setSubject(), setBodyText() or setBodyHtml() or setContent(), and finally send() method.
Methods inherited from Zend_Mail and that can be used in your code are:
- setBodyText($txt,$charset=null,$encoding=Zend_Mime::ENCODING_QUOTEDPRINTABLE)
- setBodyHtml($html,$charset=null,$encoding=Zend_Mime::ENCODING_QUOTEDPRINTABLE)
- addTo($email, $name=”)
- addCc($email, $name=”)
- addBcc($email)
- setFrom($email, $name = null)
- setReplyTo($email, $name = null)
- setReturnPath($email)
- setSubject($subject)
- addHeader($name, $value, $append = false)
Looking for PHP, Laminas or Mezzio Support?
As part of the Laminas Commercial Vendor Program, Apidemia offers expert technical support and services for:
Leave a Reply