source: sandbox/webservice/api/rest/mail/SendResource.php @ 6338

Revision 6338, 1.7 KB checked in by asaikawa, 12 years ago (diff)

Ticket #2507 - Implementacao do recurso SendResource? para envio de email

  • Property svn:executable set to *
Line 
1<?php
2
3class SendResource extends MailAdapter {
4        public function post($request){
5                // to Receive POST Params (use $this->params)
6                parent::post($request);
7
8                if($this-> isLoggedIn())
9                {
10                        // parametros recuperados conforme draft
11                        $msgForwardTo           = $this->getParam("msgForwardTo");
12                        $originalMsgID          = $this->getParam("originalMsgID");
13                        $originalUserAction     = $this->getParam("originalUserAction");
14
15                        $params['input_subject']        = $this->getParam("msgSubject");
16                        $params['input_to']                     = $this->getParam("msgTo");
17                        $params['input_cc']                     = $this->getParam("msgCcTo");
18                        $params['input_cco']            = $this->getParam("msgBccTo");
19                        $params['input_replyto']        = $this->getParam("msgReplyTo");
20                        $params['body']                         = $this->getParam("msgBody");
21                        $params['type']                         = 'textplain';
22
23                        $GLOBALS['phpgw']->preferences->read_repository();
24                        $_SESSION['phpgw_info']['expressomail']['user'] = $GLOBALS['phpgw_info']['user'];
25                        $boemailadmin = CreateObject('emailadmin.bo');
26                        $emailadmin_profile = $boemailadmin->getProfileList();
27                        $_SESSION['phpgw_info']['expressomail']['email_server'] = $boemailadmin->getProfile($emailadmin_profile[0]['profileID']);
28                        $_SESSION['phpgw_info']['expressomail']['server'] = $GLOBALS['phpgw_info']['server'];
29                        $_SESSION['phpgw_info']['expressomail']['user']['email'] = $GLOBALS['phpgw']->preferences->values['email'];
30
31                        $expressoMail = CreateObject('expressoMail1_2.imap_functions');
32                        $returncode   = $expressoMail->send_mail($params);
33
34                        if (!$returncode || !(is_array($returncode) && $returncode['success'] == true))
35                                Errors::runException("MAIL_NOT_SENT");
36                }
37
38                $this->setResult(true);
39
40                //to Send Response (JSON RPC format)
41                return $this->getResponse();
42        }
43
44}
Note: See TracBrowser for help on using the repository browser.