Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $app->post('/sendemail', function ($request, $response) {
- //Save info process
- $message = saveDataBaseInfo();
- if ($message == "OK") {
- // Send email
- $res = sendEmail("Some text", "<p>Some text</p>", "Some subject", "email@email.com");
- if ($res == "Fail") {
- return $res;
- } else {
- return Functions::createMessageReturnToClient("", Types::EnviarMensagem, $message);
- }
- }
- });
- public function sendEmail($body, $bodyHtml, $subject, $emailTo) {
- $mail = new PHPMailer;
- $mail->SingleTo = true;
- $mail->isSMTP();
- $mail->Host = 'myHost';
- $mail->SMTPAuth = true;
- $mail->Username = 'theuser';
- $mail->Password = '******';
- $mail->SMTPSecure = 'tls';
- $mail->Port = 587;
- $mail->setFrom("emailfrom@emailfrom.com", "", false);
- $mail->addAddress($emailTo);
- $mail->isHTML(true);
- $mail->Subject = $subject;
- $mail->Body = $bodyHtml;
- $mail->AltBody = $body;
- $send = $mail->send();
- if (!$send) {
- return "Success"
- } else {
- return "Fail";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement