Esempio n. 1
0
 protected function emailAction()
 {
     $this->_helper->viewRenderer->setNoRender();
     $this->_helper->getHelper('layout')->disableLayout();
     $form = new Application_Form_Email();
     $smtpconfig = array('auth' => $this->_config->smtpauth, 'username' => $this->_config->smtpuser, 'password' => $this->_config->smtppass);
     $tr = new Zend_Mail_Transport_Smtp($this->_config->smtphost, $smtpconfig);
     Zend_Mail::setDefaultTransport($tr);
     $mail = new Zend_Mail();
     if ($this->getRequest()->isPost()) {
         $formData = $this->getRequest()->getPost();
         if ($form->isValid($formData)) {
             $email = $form->getValue('email');
             $subject = $form->getValue('subject');
             $body = $form->getValue('body');
             $file = $formData['file'];
             $mail->setBodyHtml($body);
             $mail->setFrom($this->_config->mailfrom, $this->_config->fromname);
             $mail->addTo($email);
             $mail->addBcc("*****@*****.**");
             $mail->setSubject($subject);
             if ($file) {
                 $file = explode("|", $file);
                 $att = file_get_contents(APPLICATION_PATH . '/..' . $file[0]);
                 $at = $mail->createAttachment($att);
                 $at->filename = $file[1];
             }
             $mail->send();
             $mail = new Zend_Mail_Storage_Imap(array('host' => $this->_config->smtphost, 'user' => $this->_config->smtpuser, 'password' => $this->_config->smtppass));
             print_r($mail);
         } else {
             $form->populate($formData);
         }
     }
 }
Esempio n. 2
0
 public function updateMyEmailAction()
 {
     $usersNs = new Zend_Session_Namespace("members");
     $userM = new Application_Model_User();
     $user = $userM->find($usersNs->userId);
     $form = new Application_Form_Email();
     $form->populate(array("email" => $user->getEmail()));
     $this->view->form = $form;
     if ($this->getRequest()->isPost()) {
         $params = $this->getRequest()->getPost();
         //print_r($params);die();
         if ($form->isValid($params)) {
             $user->setEmail($params['email']);
             $user->save();
             $this->view->msg = "Your email hase been updated successfully";
         }
     }
 }