Proyectos de Subversion LeadersLinked - Services

Rev

Rev 289 | Rev 292 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 289 Rev 291
Línea 25... Línea 25...
25
use LeadersLinked\Mapper\AbuseReportMapper;
25
use LeadersLinked\Mapper\AbuseReportMapper;
26
use LeadersLinked\Model\AbuseReport;
26
use LeadersLinked\Model\AbuseReport;
27
use LeadersLinked\Library\ExternalCredentials;
27
use LeadersLinked\Library\ExternalCredentials;
28
use LeadersLinked\Library\Storage;
28
use LeadersLinked\Library\Storage;
29
use LeadersLinked\Form\InMail\SendForm;
29
use LeadersLinked\Form\InMail\SendForm;
-
 
30
use PHPMailer\PHPMailer\PHPMailer;
Línea 30... Línea 31...
30
 
31
 
31
 
32
 
32
class InMailController extends AbstractActionController
33
class InMailController extends AbstractActionController
Línea 742... Línea 743...
742
            if ($form->isValid()) {
743
            if ($form->isValid()) {
Línea 743... Línea 744...
743
                
744
                
Línea 744... Línea 745...
744
                $dataPost = (array) $form->getData();
745
                $dataPost = (array) $form->getData();
-
 
746
                
-
 
747
                try { 
-
 
748
                    
-
 
749
                    $subject = $dataPost['subject'];
-
 
750
                    $message = $dataPost['body'];
-
 
751
                    
-
 
752
                    $encoding = mb_detect_encoding($subject);
-
 
753
                    if($encoding != 'UTF-8') {
-
 
754
                        $subject = mb_convert_encoding($subject, 'UTF-8', $encoding);
-
 
755
                    }
-
 
756
                    
-
 
757
                    $encoding = mb_detect_encoding($message);
-
 
758
                    if($encoding != 'UTF-8') {
-
 
759
                        $message = mb_convert_encoding($message, 'UTF-8', $encoding);
-
 
760
                    }
-
 
761
                    
-
 
762
                    
-
 
763
                   
-
 
764
                    
-
 
765
                    
-
 
766
                    
-
 
767
                    $phpMailer = new PHPMailer();
-
 
768
                    $phpMailer->isSMTP();
-
 
769
                    
-
 
770
                    $phpMailer->addAddress($user->username_inmail, ($user->first_name . ' ' . $user->last_name));
-
 
771
                   /*
-
 
772
                    if($cc) {
-
 
773
                        foreach($cc as $address => $name) {
-
 
774
                            $phpMailer->addCC($address, $name);
-
 
775
                        }
-
 
776
                    }
-
 
777
                    if($bcc) {
-
 
778
                        foreach($bcc as $address => $name) {
-
 
779
                            $phpMailer->addBCC($address, $name);
-
 
780
                        }
-
 
781
                    }*/
-
 
782
                    
-
 
783
                    $phpMailer->setFrom($currentUser->username_inmail, ($currentUser->first_name . ' ' . $currentUser->last_name));
-
 
784
                    $phpMailer->SMTPDebug    = true;
-
 
785
                    $phpMailer->Host         = $host;
-
 
786
                    $phpMailer->Port         = $port;
-
 
787
                    $phpMailer->IsHTML(true);
-
 
788
                    $phpMailer->SMTPAuth    = true;
-
 
789
                    //$phpMailer->SMTPSecure   = 'tls';
-
 
790
                    $phpMailer->SMTPAuth     = false;
-
 
791
                    $phpMailer->Username     = $username;
-
 
792
                    $phpMailer->Password     = $password;
-
 
793
                    $phpMailer->Subject      = $subject;
-
 
794
                    $phpMailer->Body         = $message;
-
 
795
                    $phpMailer->AltBody      = $message;
-
 
796
                    $phpMailer->CharSet      = 'UTF-8';
-
 
797
                    
-
 
798
                    $files  = $this->getRequest()->getFiles()->toArray();
-
 
799
                    if (isset($files['filename']) && empty($files['filename']['error'])) {
-
 
800
                        $phpMailer->addAttachment($files['filename']['tmp_name'], $files['filename']['name'] );
-
 
801
                        
-
 
802
                    }
-
 
803
  
-
 
804
                    if($phpMailer->send()) {
-
 
805
                        
-
 
806
                        return new JsonModel([
-
 
807
                            'success'   => true,
-
 
808
                            'data'   => 'LABEL_INMAIL_MESSAGE_SENT'
-
 
809
                        ]);
-
 
810
                    } else {
-
 
811
                        return new JsonModel([
-
 
812
                            'success'   => false,
-
 
813
                            'data'   => 'ERROR_INMAIL_MESSAGE_NOT_SENT'
-
 
814
                        ]);
-
 
815
                    }*/
-
 
816
                    
-
 
817
                    
745
                
818
                    /*
746
                try { 
819
                    
747
                    \Eden\Core\Control::i();
820
                    \Eden\Core\Control::i();
748
                    $smtp = eden('mail')->smtp(
821
                    $smtp = eden('mail')->smtp(
749
                        $host,
822
                        $host,
Línea 766... Línea 839...
766
                    
839
                    
Línea 767... Línea 840...
767
                    
840
                    
Línea 768... Línea 841...
768
                    
841
                    
769
                    $smtp->send();
842
                    $smtp->send();
770
                    
843
                    
771
                    $smtp->disconnect(); 
844
                    $smtp->disconnect(); */