SetTitle("Отправка анкеты");?> 'MIME-Version: 1.0', 'type' => 'Content-Type: multipart/mixed; boundary="%s"', 'from' => null, 'date' => null, 'version' => 'X-Mailer: PHPMailer version %s'); private $subject; private $message; private $charset; private $signature; const charset = 'Windows-1251'; public function __construct(){ mb_internal_encoding(self::charset); $this->finfo = new finfo(FILEINFO_MIME_TYPE); $this->boundary = md5(uniqid(rand(),1)); $this->header['type'] = sprintf($this->header['type'], $this->boundary); $this->header['version'] = sprintf($this->header['version'], phpversion()); } public function set_header($mails = array(), $to_name = null, $from_mail = null, $from_name = null, $subject = null, $charset = 'utf-8'){ $this->charset = self::detect_charset($charset); $this->mails = $this->attachments = array(); $this->header['from'] = $this->message = $this->signature = null; $this->to_name = (trim($to_name))?trim($to_name):null; $this->subject = (trim($subject))?mb_encode_mimeheader(trim($subject), $this->charset):null; if (!is_array($mails)) $mails = explode(',', $mails); foreach (array_map('trim', $mails) as $mail){ if (filter_var($mail, FILTER_VALIDATE_EMAIL)) $this->mails[] = $mail; } if (trim($from_name)) $this->header['from'] = mb_encode_mimeheader('From: '.$from_name, $this->charset, 'B', '', 6); if (filter_var($from_mail, FILTER_VALIDATE_EMAIL)) { if (!$this->header['from']) $this->header['from'] = mb_encode_mimeheader('From: '.$from_mail, $this->charset, 'B', '', 6); $this->header['from'] .= '<'.trim(mb_strtolower($from_mail)).'>'; } return $this; } public function message($message, $type = 'text/plain', $encoding = 'base64'){ $message = $this->encode_text($message, $encoding, $type); $this->message .= sprintf("\r\n\r\n--%s\r\n", $this->boundary); $this->message .= "Content-Disposition: inline\r\n"; $this->message .= sprintf("Content-Transfer-Encoding: %s\r\n", $encoding); $this->message .= sprintf("Content-Length: %u\r\n", mb_strlen($message)); $this->message .= sprintf("Content-Type: %s; charset=%s\r\n\r\n", $type, $this->charset); $this->message .= $message; return $this; } public function attachments(){ foreach (func_get_args() as $attach){ if ($attach == '.' || $attach == '..') continue; if (is_array($attach)) call_user_func_array(array($this, __METHOD__), $attach); elseif (is_dir($attach)) call_user_func_array(array($this, __METHOD__), scandir($attach)); elseif (is_file($attach)){ $filename = basename(realpath($attach)); $block = sprintf("\r\n\r\n--%s\r\n", $this->boundary); $block .= sprintf("Content-Disposition: attachment; filename=\"%s\"\r\n", $filename); $block .= "Content-Transfer-Encoding: base64\r\n"; $block .= sprintf("Content-Type: %s; name=\"%s\"\r\n", $this->finfo->file($attach), $filename); $block .= sprintf("Content-ID: attach%u\r\n\r\n", sizeof($this->attachments)); $block .= chunk_split(base64_encode(file_get_contents($attach))); $this->attachments[] = $block; } } } public function signature($signature, $style = null, $encoding = 'base64'){ $signature = $this->encode_text(''.$signature.'', $encoding); $this->signature = sprintf("\r\n\r\n--%s\r\n", $this->boundary); $this->signature .= "Content-Disposition: inline\r\n"; $this->signature .= sprintf("Content-Transfer-Encoding: %s\r\n", $encoding); $this->signature .= sprintf("Content-Length: %u\r\n", mb_strlen($signature)); $this->signature .= sprintf("Content-Type: text/html; charset=%s\r\n\r\n", $this->charset); $this->signature .= $signature; } static private function detect_charset($charset){ $encodings = mb_list_encodings(); $upper = array_map('mb_strtoupper', $encodings); $aliases = @mb_encoding_aliases($charset); if ($aliases){ foreach ($aliases as $alias){ if (($k = array_search($alias, $upper)) !== false){ return (in_array(mb_strtoupper(self::charset), mb_encoding_aliases($encodings[$k])))?self::charset:$encodings[$k]; } } } return self::charset; } private function encode_text($data, $encoding, $type = 'text/html'){ if (is_file($data)) $data = file_get_contents($data); if ($this->charset != self::charset) $data = mb_convert_encoding($data, $this->charset); if (mb_strpos($type, 'html') !== false && mb_strpos($data, '') === false){ $data = ''.$data.''; } switch (mb_strtolower($encoding)){ case 'base64': return base64_encode($data); break; default: return $data; } } public function send(){ if (sizeof($this->mails)){ $message = $this->message.implode($this->attachments).$this->signature."\r\n\r\n--".$this->boundary."--\r\n"; if ($this->to_name && sizeof($this->mails) === 1) $this->mails[0] = mb_encode_mimeheader(trim($this->to_name), $this->charset, 'B', '').'<'.mb_strtolower($this->mails[0]).'>'; $this->header['date'] = 'Date: '.date('r'); $this->header = array_diff($this->header, array('')); return mail(implode(',', $this->mails), $this->subject, $message, implode("\r\n", $this->header)); } return false; } } $message = ' Анкета соискателя

Анкета соискателя, заполненная на сайте abisoft.ru

Анкета на должность: ' . $_GET['in_1'] . '
Фамилия, Имя, Отчество: ' . $_GET['in_2'] . '
Гражданство: ' . $_GET['in_3'] . '
Дата и место рождения: ' . $_GET['in_4'] . '
Адрес прописки: ' . $_GET['in_5'] . '
Адрес проживания: ' . $_GET['in_6'] . '
Телефон: ' . $_GET['in_7'] . '
Электронная почта: ' . $_GET['in_8'] . '
Желаемый уровень з/п: ' . $_GET['in_9'] . '
Образование: ' . $_GET['in_10'] . '
Знание компьютера: ' . $_GET['in_11'] . '
Опыт работы: ' . $_GET['in_12'] . '
Свободно о себе: ' . $_GET['in_13'] . '
'; $mail = new mailer; //$mail->set_header('sergey@oliwa-pro.ru', 'Менеджер abisoft', 'info@abisoft.ru', 'Администратор abisoft.ru', /*job@abisoft.ru*/ 'Анкета соискателя bitrix'); $mail->set_header(array('job@abisoft.ru'), 'Менеджер abisoft', 'info@abisoft.ru', 'Администратор abisoft.ru', /*job@abisoft.ru*/ 'Анкета соискателя bitrix'); $mail->message($message, 'text/html'); if ($mail->send()) echo '

Письмо отправлено

'; else echo '

Возникла ошибка при отправке анкеты, свяжитесь с нами по телефону.

';?>