Guest User

Untitled

a guest
May 27th, 2018
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.30 KB | None | 0 0
  1. function SendEMailZend($to, $subject, $body, $cc=null, $bcc=null, $attachment=null){
  2.     $pconf = new ParametriConfigurazione();
  3.     $from=$pconf->Get('from_email');
  4.  
  5.     $tr = new Zend_Mail_Transport_Sendmail();
  6.     Zend_Mail::setDefaultTransport($tr);
  7.  
  8.     $mail = new Zend_Mail('UTF-8');
  9.     $mail->setBodyText($body);
  10.     $mail->setFrom($from, 'Trinity College London');
  11.  
  12.     if(is_array($to)){
  13.         foreach($to as $to_address){
  14.             $mail->addTo($to);
  15.         }
  16.     }else{
  17.         $mail->addTo($to);
  18.     }
  19.  
  20.     if(is_array($cc)){
  21.         foreach ($cc as $cc_address){
  22.             $mail->addCc($cc_address);
  23.         }
  24.     }else if(!is_null($cc)){
  25.         $mail->addCc($cc);
  26.     }
  27.  
  28.     if(is_array($bcc)){
  29.         foreach($bcc as $bcc_address){
  30.             $mail->addBcc($bcc_address);
  31.         }
  32.     }else if(!is_null($bcc)){
  33.         $mail->addBcc($bcc);
  34.     }
  35.  
  36.     if(!is_null($attachment)){
  37.         $at = new Zend_Mime_Part($attachment['content']);
  38.         $at->type        = $attachment['mime'];
  39.         $at->disposition = Zend_Mime::DISPOSITION_INLINE;
  40.         $at->encoding    = Zend_Mime::ENCODING_BASE64;
  41.         $at->filename    = $attachment['filename'];
  42.          
  43.         $mail->addAttachment($at);
  44.     }
  45.  
  46.     $mail->setSubject($subject);
  47.     $mail->send();
  48. }
Add Comment
Please, Sign In to add comment