public static function MySend($array) { global $INI, $app; if (isset($INI["mailserver"]) && $INI["mailserver"]) { $mailer = new Mailer(); $mailer->isSMTP(); $mailer->SMTPOptions = ['ssl' => ['verify_peer' => false, 'verify_peer_name' => false, 'allow_self_signed' => true]]; $mailer->Host = $INI["mailserver"]; if (isset($INI["maildebug"]) && $INI["maildebug"]) { $mailer->SMTPDebug = 2; } if (isset($INI["mailuser"]) && $INI["mailuser"] && isset($INI["mailpwd"]) && $INI["mailpwd"]) { $mailer->SMTPAuth = true; $mailer->Username = $INI["mailuser"]; $mailer->Password = $INI["mailpwd"]; $mailer->Port = $INI["mailport"]; } $mailer->isHTML(true); if (is_array($array["from"])) { $mailer->setFrom($array["from"][0], $array["from"][1]); } else { $mailer->setFrom($array["from"]); } if (is_array($array["to"])) { $mailer->addAddress($array["to"][0], $array["to"][1]); } else { $mailer->addAddress($array["to"]); } if (isset($array["reply"])) { if (is_array($array["reply"])) { $mailer->addReplyTo($array["reply"][0], $array["reply"][1]); } else { $mailer->addReplyTo($array["reply"]); } } if (isset($array["bcc"])) { if (is_array($array["bcc"])) { foreach ($array["bcc"] as $bcc) { $mailer->addBCC($bcc); } } else { $mailer->addBCC($array["bcc"]); } } $mailer->Subject = $array["subject"]; $mailer->Body = $array["body"]; if (isset($array["attachments"])) { foreach ($array["attachments"] as $a) { $mailer->addAttachment($a); } } $mailer->send(); } else { if (isset($INI["maildebug"]) && $INI["maildebug"]) { $file = fopen($app->basePathname("cache/debug.txt"), "a"); fwrite($file, "Sending to: " . join(" ; ", mklist($array["to"]))); fwrite($file, "\n{$array['body']}\n----------\n"); fclose($file); } } }
/** * @param $seller * @param $pdf * @throws Exception * @throws phpmailerException */ private function _createBuyerMail($buyer, medexchange_pdf_medorder_BuyerPDF $pdf) { $mail = new Mailer(); $mail->Subject = 'Sie haben Artikel gekauft'; $buyerObj = Factory::loadObject('user', $buyer); $mail->Body = "Hallo " . $buyerObj['userid'] . "\n\n"; $mail->Body .= "es wurden Artikel von Ihnen gekauft. Bitte ueberpruefen Sie das Dokument im Anhang.\n\n"; $mail->Body .= "Mit freundlichen Gruessen \n\nIhr medEXchange-Team"; $mail->addAddress($buyerObj['email']); $mail->addAttachment($pdf->getPath()); $mail->send(); }
<?php if (!isset($_POST['name'])) { die; } require __DIR__ . '/Validator.php'; require __DIR__ . '/Mailer.php'; $validator = new Validator(); if (!$validator->validate()) { echo json_encode(array('success' => 'false', 'errors' => $validator->getErrors())); die; } $mail = new Mailer(); $mail->addAddress("*****@*****.**"); $msg = "\nHallo,<br /><br />\n\nHet contactformulier op uw website is ingevuld. Hieronder staan de ingevoerde gegevens:<br /><br />\n\n<table>"; if (isset($_POST['message'])) { $_POST['message'] = nl2br($_POST['message']); } foreach ($_POST as $key => $value) { if (is_array($value)) { $value = implode(", ", $value); } $msg .= "<tr>\n <td>" . $key . "</td>\n <td>" . $value . "</td>\n</tr>"; } $msg .= "</table><br />"; $mail->setHTMLBody($msg); if ($mail->send()) { echo json_encode(array('success' => true)); exit; } echo json_encode(array('success' => false));
public function resetPassword() { $this->view = new HTMLView(); if ($this->request->isPOST()) { $post = $this->request->postData(); $user = new UserModel(); if ($this->request->isQueryArgSet('token')) { if ($user->getUserForPasswordResetToken($this->request->queryArgValue('token'))) { $user->password = @$post['password']; if ($user->save()) { $user->deletePasswordResetTokens(); $alert = new Alert(Alert::SUCCESS); $alert->addMessage('Password Set, Please Login'); } else { $alert = new Alert(Alert::ERROR); $alert->addMessageArray($user->getErrors()); } $this->view->includeTemplate('auth.reset-password.password', ['app_name' => AppConfig::getValue('app_name'), 'alert' => $alert]); } else { AppController::redirect(RouteController::fqURL('resetPassword'), ['status' => 'token-expired']); } } else { if ($post['email'] && $user->find($post['email'], 'email')) { $token = $user->getPasswordResetTokenData(); if ($token['last_email_timestamp'] <= Carbon::now()->subMinutes(pow(2, $token['email_attempts']))) { $user->incrementPasswordResetEmailCount(); $link = addQueryParams(RouteController::fqURL('resetPassword'), ['token' => $token['token']]); // Send Email $mailer = new Mailer(); $mailer->setSubject('Password Reset Token'); $mailer->addAddress($user->email); $mailer->includeHTMLTemplate('email.reset-password', ['link' => $link]); $mailer->send(); // errors handled within // Show Message $alert = new Alert(Alert::SUCCESS); $alert->addMessage('Email Sent'); } else { $alert = new Alert(Alert::ERROR); $alert->addMessage('Too Many Attempts, Please Try Again Later'); } $this->view->includeTemplate('auth.reset-password.email', ['app_name' => AppConfig::getValue('app_name'), 'alert' => $alert]); } else { $alert = new Alert(Alert::ERROR); $alert->addMessage('Email is Invalid/Non-Existent'); $this->view->includeTemplate('auth.reset-password.email', ['app_name' => AppConfig::getValue('app_name'), 'alert' => $alert]); } } } else { if ($this->request->isQueryArgSet('token')) { $user = new UserModel(); if ($user->getUserForPasswordResetToken($this->request->queryArgValue('token'))) { $this->view->includeTemplate('auth.reset-password.password', ['app_name' => AppConfig::getValue('app_name')]); } else { AppController::redirect(RouteController::fqURL('resetPassword'), ['status' => 'token-expired']); } } else { if ($this->request->isQueryArgSet('status') && $this->request->queryArgValue('status') == 'token-expired') { $alert = new Alert(Alert::ERROR); $alert->addMessage('Token is Invalid/Expired, Please Request a New One'); } $this->view->includeTemplate('auth.reset-password.email', ['app_name' => AppConfig::getValue('app_name'), 'alert' => isset($alert) ? $alert : null]); } } $this->view->render(true); }