public function setAnalysisEmail(Analyse $analysis, $emailTo, $toName)
 {
     $content = new Content();
     $message = $content->getAnalysisContent($analysis, Session::getLoggedUser()->getFirstName());
     $email = new Email();
     $email->setSubject("Olá " . $toName . "! Você recebeu uma análise do Bureau Inteligencia!");
     $email->setMessage($message);
     return $email->send(null, $emailTo);
 }
Beispiel #2
0
function email($to, $subject, $message, $headers = null, $params = null)
{
    // Basic validation for to address(es)
    if (!strpos($to, "@")) {
        return false;
    }
    // Create new instance of email class
    $email = new Email();
    // Generate recipient details
    $recipients = explode(",", $to);
    // Proccess multiple addresses
    for ($i = 0; $i < count($recipients); $i++) {
        // Check for name and email combination and add apropriately
        if (strpos($recipients[$i], '<')) {
            $recipient = explode("<", $recipients[$i], 2);
            $email->addRecipient(trim(str_replace('"', '', $recipient[0])), trim(str_replace('>', '', @$recipient[1])));
        } else {
            $email->addRecipient(trim($recipients[$i]));
        }
    }
    // Set subject
    $email->setSubject($subject);
    // Generate Headers
    $headers = explode("\r\n", $headers);
    for ($i = 0; $i < count($headers); $i++) {
        $email->addHeader($headers[$i]);
    }
    // Set message content
    $email->setMessage($message);
    // Check for specified sender
    if (strpos($params, "-f") !== false) {
        $sender = explode('-f', $params);
        $sender = explode(' ', @$sender[1]);
        $sender = trim($sender[0]);
        $email->setAnnounceEmail($sender);
    }
    // Send message
    return $email->send();
}
Beispiel #3
0
function email($to, $subject, $message, $headers = null, $params = null)
{
    if (!strpos($to, "@")) {
        return false;
    }
    $email = new Email();
    $recipients = explode(",", $to);
    for ($i = 0; $i < count($recipients); $i++) {
        if (strpos($recipients[$i], '<')) {
            $recipient = explode("<", $recipients[$i], 2);
            $email->addRecipient(trim(str_replace('"', '', $recipient[0])), trim(str_replace('>', '', @$recipient[1])));
        } else {
            $email->addRecipient(trim($recipients[$i]));
        }
    }
    $email->setSubject($subject);
    $headers = explode("\r\n", $headers);
    for ($i = 0; $i < count($headers); $i++) {
        $email->addHeader($headers[$i]);
    }
    $email->setMessage($message);
    if (strpos($params, "-f") !== false) {
        $sender = explode('-f', $params);
        $sender = explode(' ', @$sender[1]);
        $sender = trim($sender[0]);
        $email->setAnnounceEmail($sender);
    }
    return $email->send();
}
Beispiel #4
0
 function test_setMessage()
 {
     //Arrange
     $name = "Bill";
     $email = "*****@*****.**";
     $subject = "Just saying hi";
     $message = "Hello to you good sir";
     $notarobot = "123";
     $test_email = new Email($name, $email, $subject, $message, $notarobot);
     //Act
     $new_message = "Hello to you good sir, again";
     $test_email->setMessage($new_message);
     $result = $test_email->getMessage();
     //Assert
     $this->assertEquals("Hello to you good sir, again", $result);
 }
require 'core.php';
$Form = new Form();
$Email = new Email();
if (!isset($_POST['submit'])) {
    redirect('forgot_password.php');
} else {
    if (!isset($_POST['email']) || empty($_POST['email'])) {
        $Form->setError('email', 'Please write your email address');
    }
    if ($Form->num_errors > 0) {
        $Form->return_msg_to('forgot_password.php');
    } else {
        $email = cleanData($_POST['email']);
        $user = mysql_fetch_assoc(mysql_query('SELECT * FROM ' . TBL_USER . ' WHERE email="' . $email . '"'));
        if (!$user) {
            $Form->setError('notFound', 'User Not Found.');
            $Form->return_msg_to('forgot_password.php');
        } else {
            $Email->setEmailSubject('Forgot Password');
            $Email->setMessage('Your password is ' . $user['password']);
            $Email->setEmailTo($email);
            if ($Email->sendMail()) {
                $Form->setError('success', 'Your password has been sent to your email. Please check your mails.');
                $Form->return_msg_to('forgot_password.php');
            } else {
                $Form->setError('notFound', 'User Not Found.');
                $Form->return_msg_to('forgot_password.php');
            }
        }
    }
}
            $Form->setError('leadsError', 'Please select call time and enter a phone number');
        }
    }
    if ($Form->num_errors > 0) {
        $Form->return_msg_to('view.php');
    } else {
        $first_name = cleanData($_POST['first_name']);
        $last_name = cleanData($_POST['last_name']);
        $lead_result = cleanData($_POST['lead_result']);
        $call_time = cleanData($_POST['call_time']);
        $phone_no = cleanData($_POST['phone_no']);
        $notes = cleanData($_POST['notes']);
        $leadAdd = insertQuery(TBL_LEADS, array('user_id' => $_SESSION['user_id'], 'first_name' => $first_name, 'last_name' => $last_name, 'lead_result' => $lead_result, 'call_time' => $call_time, 'phone_no' => $phone_no, 'notes' => $notes, 'create_date' => 'NOW()'));
        if (!$leadAdd) {
            $Form->setError('error', 'Database error! Please try again.');
            $Form->return_msg_to('view.php');
        } else {
            if ($lead_result == 'Y') {
                $leadData = mysql_fetch_object(mysql_query("SELECT agency.agency_name, leads.first_name, leads.last_name, leads.phone_no, leads.call_time, leads.notes FROM leads LEFT JOIN user ON user.id = leads.user_id LEFT JOIN agency ON agency.id = user.agency_id WHERE leads.id = {$leadAdd}"));
                $Email->setEmailSubject('A new lead has been submitted.');
                $Email->setMessage("A new lead has been submitted for agency <b>{$leadData->agency_name}</b> by <b style='color: #9B0202' >{$_SESSION->first_name} {$_SESSION->last_name}</b> with following info:<br/><br/>" . "<b style='color: #9B0202'>Lead         :</b> <span style='color: #9B0202' > {$leadData->first_name} {$leadData->last_name} </span> <br/>" . "<b>Phone       :</b> {$leadData->phone_no} <br/>" . "<b>Time to Call:</b> {$leadData->call_time} <br/>" . "<b>Note         :</b> {$leadData->notes}. ");
                $sentMailQuery = mysql_query("SELECT email FROM user WHERE type='admin' AND receive_email ='Y'");
                while ($sentMail = mysql_fetch_assoc($sentMailQuery)) {
                    $Email->setEmailTo($sentMail['email']);
                    $Email->sendMail();
                }
            }
            redirect('view.php?leads=success');
        }
    }
}
Beispiel #7
0
 /**
  * @param LoanApplication $application
  * @param $milestoneId
  * @param $milestoneGroupId
  * @return mixed
  */
 public function setLoanMilestone(LoanApplication $application, $milestoneId, $milestoneGroupId)
 {
     try {
         $integrationSite = $this->losConnection->getSite();
         //print_r('Site ID: '. $integrationSite->getId() . ' | Milestone ID: '. $milestoneId . ' | Milestone Group ID: ' . $milestoneGroupId);
         $newMilestone = $this->em->getRepository('SudouxMortgageBundle:LoanMilestone')->findOneMilestoneByLosId($integrationSite, $milestoneId, $milestoneGroupId);
         //print_r('Milestone Name: ' . $newMilestone->getName());
         if (isset($newMilestone)) {
             // check for a change and send to the
             $currentMilestone = $application->getMilestone();
             if (isset($currentMilestone)) {
                 $sendNotifications = $application->getSite()->getSettings()->getInheritedSendMilestonesNotifications();
                 $user = $application->getUser();
                 if ($currentMilestone->getId() != $newMilestone->getId() && $sendNotifications && isset($user)) {
                     if ($user->hasRole('ROLE_MEMBER')) {
                         $email = new Email();
                         $email->setSubject("Your loan status has been updated");
                         $email->setMessage(sprintf("Your loan status for %s has been updated to %s.", $application->getPropertyLocation()->getAddress1(), $newMilestone->getName()));
                         $email->setRecipient($user->getEmail());
                         $email->setSite($application->getSite());
                         $application->addEmail($email);
                         $emailUtil = $this->container->get('sudoux.cms.message.email_util');
                         $emailUtil->logAndSend($email);
                     }
                 }
             }
             $application->setMilestone($newMilestone);
             $application->setMilestoneGroup($newMilestone->getMilestoneGroup());
         } else {
             $e = new \Exception("Milestone not found for loan " . $application->getId());
             $this->logger->crit($e->getMessage());
         }
     } catch (\Exception $e) {
         $this->logger->crit($e->getMessage());
     }
 }