inbox = imap_open("{" . MAIL_SERVER . ":" . MAIL_SERVER_PORT . MAIL_SERVER_FLAGS . "}INBOX", MAIL_USER, MAIL_PASSWORD) or die("can't connect:" . imap_last_error()); } public function __destruct() { imap_close($this->inbox); } public function getNewMessages() { return imap_search($this->inbox, 'UNSEEN'); } public function fetchMessageStructure($email) { return imap_fetchstructure($this->inbox, $email); } public function fetchMessageBody($email, $section) { return imap_fetchbody($this->inbox, $email, $section); } public function headerInfo($email) { $headerInfo = imap_headerinfo($this->inbox, $email); $additionalHeaderInfo = imap_fetchheader($this->inbox, $email); $infos = explode("\n", $additionalHeaderInfo); foreach($infos as $info) { $data = explode(":", $info, 2); if( count($data) == 2 && !isset($head[$data[0]])) { if(trim($data[0]) === 'X-Original-To') { $headerInfo->{'X-Original-To'} = trim($data[1]); // break; } else if(trim($data[0]) === 'Message-ID') { $headerInfo->{'Message-ID'} = trim($data[1]); } else if(trim($data[0]) === 'In-Reply-To') { $headerInfo->{'In-Reply-To'} = trim($data[1]); } } } return $headerInfo; } public function reply($sender, $sendername, $response = null) { $server = NC_SERVER; if(strstr($server, "https://")) { $server = str_replace('https://', '', $server); } else if(strstr($server, "http://")) { $server = str_replace('http://', '', $server); } $mail = new PHPMailer(true); try { $mail->isSMTP(); $mail->Host = MAIL_SERVER; $mail->SMTPAuth = true; $mail->Username = MAIL_USER; $mail->Password = MAIL_PASSWORD; $mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS; $mail->Port = MAIL_SERVER_SMTPPORT; $mail->setFrom(MAIL_USER, 'Mail2Deck Notification'); $mail->isHTML(true); $mail->SMTPOptions = [ 'ssl' => [ 'verify_peer' => false, 'verify_peer_name' => false, 'allow_self_signed' => true, ], ]; if($response) { $body = "
We received your request and opened a support ticket. You can see it here: board}/card/{$response->id}" . "\">Newroco Support.
" ."To access the card, you will be asked to login, please use your company usual account details.
" ."Please add more details or respond to any comments from our team, so we can address the issue as fast as possible.
Thank you for reaching out.
Make sure the board was setup correctly.
"; $subject = "A new card could not be created!"; } //Inline image $description = $response->description; $pattern = '/\[(.*?)\]\((.*?)\)/'; if (preg_match($pattern, $description)) { $descriptionFormatted = preg_replace('/\[(.*?)\]\((.*?)\)/', '$1', $description); } $bodySupport="board}/card/{$response->id}" . "\">{$response->title}
" ."{$descriptionFormatted}
" ."Sent by: {$sender}
"; /** * EMAIL 1: email to sender */ $mail->addAddress($sender); $mail->Subject = $subject; $mail->Body = "" ."