ZendMail provides generalized functionality to compose and send both text and MIME-compliant multipart email messages. Mail can be sent with ZendMail via the MailTransportSendmail, MailTransportSmtp or the MailTransportFile transport. Of course, you can also implement your own transport by implementing the MailTransportTransportInterface
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
// for email library use ZendMail; use ZendMimeMessage as MimeMessage; use ZendMimePart as MimePart; // send email , place this function in your controller function sendMail($htmlBody, $textBody, $subject, $from, $to) { $htmlPart = new MimePart($htmlBody); $htmlPart->type = "text/html"; $textPart = new MimePart($textBody); $textPart->type = "text/plain"; $body = new MimeMessage(); $body->setParts(array($textPart, $htmlPart)); $message = new MailMessage(); $message->setFrom($from); $message->addTo($to); $message->setSubject($subject); $message->setEncoding("UTF-8"); $message->setBody($body); $message->getHeaders()->get('content-type')->setType('multipart/alternative'); $transport = new MailTransportSendmail(); $transport->send($message); } |
I hope you like this Post, Please feel free to comment below, your suggestion and problems if you face - we are here to solve your problems.
I am Arjun from Hyderabad (India). I have been working as a software engineer from the last 7+ years, and it is my passion to learn new things and implement them as a practice. Aside from work, I like gardening and spending time with pets.