from = $from; } /* Изменение обратного e-mail адреса */ public function setFrom($from) { $this->from = $from; } /* Изменение имени в обратном адресе */ public function setFromName($from_name) { $this->from_name = $from_name; } /* Изменение типа содержимого письма */ public function setType($type) { $this->type = $type; } /* Нужно ли запрашивать подтверждение письма */ public function setNotify($notify) { $this->notify = $notify; } /* Изменение кодировки письма */ public function setEncoding($encoding) { $this->encoding = $encoding; } //email_from,email_from_name,email_to,subject,text /* Метод отправки письма */ public function send($to, $subject, $message) { global $name_project, $site; $smtp_api_key = 'uxeLBonxdZJAjRuSxRNXeEWCoTtU2YHmmLYN'; $fields = [ 'from' => 'support@' . server('SERVER_NAME'), 'name' => $name_project, 'subject' => $subject, 'to' => $to, 'html' => $message, ]; $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, 'https://api.smtp.bz/v1/smtp/send'); curl_setopt($curl, CURLOPT_HTTPHEADER, ['authorization: ' . $smtp_api_key, 'content-type: multipart/form-data']); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_POST, true); curl_setopt($curl, CURLOPT_POSTFIELDS, $fields); $out = curl_exec($curl); $err = curl_error($curl); //log_write($out, $err); curl_close($curl); $res = json_decode($out, true)['result']; if (!$res) { $this->errors = json_decode($out, true)['errors']['message']; } return $res; } public function getErrorMessage() { return $this->errors; } } }