PHP Freelancer Developer from India
Zend Framework
Sending Email with attachment in zend framewok
Dec 5th
In your controller, write something like this.
$myView = new Zend_View();
$myView->addScriptPath(ROOT_DIR . ‘/application/views/scripts/templates/’);
$html_body = $ myView ->render(emailExample.html’);
$mail = new Zend_Mail();
$mail->setType(Zend_Mime::MULTIPART_RELATED);
$mail->setBodyHtml($html_body);
$mail->setFrom(‘support@example.com’, ‘Example’);
$mail->addTo(‘user@abc.com’, ‘Username’);
$mail->setSubject(‘Sending email using Zend Framework’);
$mail->send();
You can also use file_get_contents() function and then use createAttachment() function.
$fileContents = file_get_contents(‘path/to/file’);
And then call a simple method called createAttachment (), as
$file = $mail->createAttachment($fileContents);
And set the name of the attachment as
$file->filename = “yourfile.doc”;
Sending Email in Zend Framework
Dec 5th
In this article I am going to discuss how to send email with SMTP authentication. Please do tell me whether it helped you or not.
You can send email using zend famework as follows:
$emial_body = “<table><tr><td>Body of the email</td></tr></table”;
$mail = new Zend_Mail();
$mail->setBodyHtml($email_body);
$mail->setFrom('support@domain.com', 'Example');
$mail->addTo('user@abc.xyz', 'Username');
$mail->setSubject('Sending email using Zend Framework');
$mail->send();
If you require SMTP authentication while sending email in zend framework, use following code: This way of sending email will help the mail going in spam.
$emial_body = “<table><tr><td>Body of the email</td></tr></table”;
$config = array('auth' => 'login','username' => "info@domainname.com",
'password' => 'password');
$transport = new Zend_Mail_Transport_Smtp('mail.domainname.com', $config);
$mail = new Zend_Mail();
$mail->setBodyHtml($email_body);
$mail->setFrom('support@domain.com', 'Example');
$mail->addTo('user@abc.xyz', 'Username');
$mail->setSubject('Sending email using Zend Framework');
$mail->send($transport);
Recent Comments