Sending Email with attachment in Zend Framework


Note : You must remember add ( <form enctype=”multipart/form-data” > ) in form tag.

<?php
$message=”<table><tr><td>Body of the email</td></tr></table>” ;
$subject = ‘Attachement Email’;

$config = array(‘auth’ => ‘login’,
‘username’ => ‘Email Id’, 
‘password’ => ‘xxxxxxx’); 

// SMTP must be change according to Mail Server

$transport = new Zend_Mail_Transport_Smtp(‘mail.gmail.com’, $config);

$mail = new Zend_Mail();

$mail->setType(Zend_Mime::MULTIPART_RELATED);
$mail->setBodyText($message);
$mail->setBodyHtml($message);
$mail->setFrom(”info@gmail.com.”,”userName”);
$mail->addTo(’email@gmail.com’);
$mail->setSubject($subject);
$fileContents = file_get_contents($_FILES[‘Attachment’][‘tmp_name’]); // To Be Required Attachement File name
$at=$mail->createAttachment($fileContents);
$at->filename = $_FILES[‘Attachment’][‘name’]; // To Be Required Attachement File name

$mail->send($transport);

21 thoughts on “Sending Email with attachment in Zend Framework

  1. Pingback: My Homepage
  2. Hello There. I found your weblog the usage of msn. This is an extremely well written article. I will make sure to bookmark it and come back to read more of your useful information. Thank you for the post. I will certainly return.

  3. Wonderful perform! This is actually the types of facts that needs to be discussed around the web. Feel bad for on the seek out search engines without more time location this kind of offered bigger! Think about it over plus pay a visit to this web site. Thanks a lot Means)

  4. Pingback: artykuły
  5. Pingback: discover more
  6. Pingback: Waking Up Early
  7. Pingback: his explanation
  8. Pingback: affiliate Amazon
  9. I have been exploring for a bit for any high quality articles or
    blog posts in this kind of house . Exploring in Yahoo I at last stumbled
    upon this site. Studying this info So i’m glad to convey that I have a very just right uncanny feeling I found out just what I needed. I most indubitably will make sure to do not put out of your mind this site and give it a glance on a constant basis.

  10. Pingback: Earn Points
  11. Pingback: GranuFlo lawsuit
  12. Pingback: read more
  13. Hi there! This post could not be written any better!
    Reading through this post reminds me of my previous room mate!
    He always kept talking about this. I will forward this article to him.

    Pretty sure he will have a good read. Thanks for sharing!

Leave a comment