public function testAddToWithDeprectedMailClass()
 {
     $mail = new SendGrid\Mail();
     $mail->addTo('*****@*****.**');
     $this->assertEquals(array('*****@*****.**'), $mail->getTos());
     $mail->addTo('*****@*****.**');
     $this->assertEquals(array('*****@*****.**', '*****@*****.**'), $mail->getTos());
 }
Ejemplo n.º 2
0
 public static function SendEmail($sTo, $sSubject, $sTemplate, $sVariable)
 {
     global $sPanelURL;
     global $sPanelMode;
     global $sTitle;
     global $locale;
     $sEmail = Templater::AdvancedParse('/email/' . $sTemplate, $locale->strings, array("EmailVars" => array("entry" => $sVariable)));
     $sMail = Core::GetSetting('mail');
     $sMail = $sMail->sValue;
     if ($sMail == 1) {
         $sSendGridUser = Core::GetSetting('mail_username');
         $sSendGridPass = Core::GetSetting('mail_password');
         $sSendGridUser = $sSendGridUser->sValue;
         $sSendGridPass = $sSendGridPass->sValue;
         if (!empty($sSendGridUser) && !empty($sSendGridPass)) {
             $sGrid = new SendGrid($sSendGridUser, $sSendGridPass);
             $sMail = new SendGrid\Mail();
             $sMail->addTo($sTo)->setFrom("noreply@{$sPanelURL->sValue}")->setSubject($sSubject)->setHtml($sEmail);
             $sGrid->web->send($sMail);
             return true;
         } else {
             return $sReturn = array("content" => "Unfortunately Send Grid is incorrectly configured!");
         }
     } elseif ($sMail == 2) {
         $sMandrillUser = Core::GetSetting('mail_username');
         $sMandrillPass = Core::GetSetting('mail_password');
         $sMandrillUser = $sMandrillUser->sValue;
         $sMandrillPass = $sMandrillPass->sValue;
         try {
             $sMandrill = new Mandrill($sMandrillPass);
             $sMessage = array('html' => $sEmail, 'subject' => $sSubject, 'from_email' => "noreply@{$sPanelURL->sValue}", 'from_name' => "{$sTitle->sValue}", 'to' => array(array('email' => $sTo, 'type' => 'to')), 'important' => true, 'track_opens' => null, 'track_clicks' => null, 'auto_text' => null, 'auto_html' => null, 'inline_css' => null, 'url_strip_qs' => null, 'preserve_recipients' => null, 'view_content_link' => null, 'tracking_domain' => null, 'signing_domain' => null, 'return_path_domain' => null, 'merge' => true);
             $sAsync = false;
             $sIPPool = 'Main Pool';
             $sSendAt = NULL;
             $sResult = $sMandrill->messages->send($sMessage, $sAsync, $sIPPool, $sSendAt);
         } catch (Exception $e) {
             return $sReturn = array("content" => "Mandril Error: {$e}");
         }
         return true;
     } else {
         $sHeaders = "MIME-Version: 1.0" . "\r\n";
         $sHeaders .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
         $sHeaders .= 'From: <noreply@' . $sPanelURL->sValue . '>' . "\r\n";
         if (mail($sTo, $sSubject, $sEmail, $sHeaders)) {
             return true;
         } else {
             return $sReturn = array("content" => "Unfortunatly the email failed to send, please check your server's sendmail settings.");
         }
     }
 }
 function sendPlain($to, $from, $subject, $plainContent, $attachedFiles = false, $customheaders = false)
 {
     $mail = new SendGrid\Mail(SENDGRIDMAILER_USERNAME, SENDGRIDMAILER_PASSWORD);
     $sendgrid = $this->instantiate();
     if (!$from) {
         $from = SENDGRIDMAILER_MAIL;
     }
     $from_name = preg_replace('/"*(.*)"*\\<(.*)\\>/i', '$1', $from);
     if ($from_name) {
         $from = preg_replace('/"*(.*)"*\\<(.*)\\>/i', '$2', $from);
     }
     $mail->addTo($to)->setFromName($from_name)->setFrom($from)->setSubject($subject)->setText($plainContent);
     $response = $sendgrid->web->send($mail);
     SS_Log::log("{$to} | {$from} | {$from_name} | " . json_encode($response), SS_Log::INFO);
     if ($response->message == "error") {
         return false;
     }
     if ($response->message == "success") {
         return true;
     }
     return false;
 }
Ejemplo n.º 4
0
 public function testUseHeaders()
 {
     $mail = new SendGrid\Mail();
     $mail->addTo('*****@*****.**')->addBcc('*****@*****.**')->setFrom('*****@*****.**')->setSubject('Subject')->setHtml('Hello You');
     $this->assertFalse($mail->useHeaders());
     $mail->removeBcc('*****@*****.**');
     $this->assertTrue($mail->useHeaders());
     $mail->addCc('*****@*****.**');
     $this->assertFalse($mail->useHeaders());
     $mail->removeCc('*****@*****.**')->setRecipientsinHeader(true);
     $this->assertTrue($mail->useHeaders());
     $mail->setRecipientsinHeader(false);
     $this->assertFalse($mail->useHeaders());
     $mail->addBcc('*****@*****.**')->addAttachment('attachment.ext');
     $this->assertTrue($mail->useHeaders());
 }
Ejemplo n.º 5
0
    include 'email_validation.php';
    $name = stripslashes($_POST['name']);
    $email = trim($_POST['email']);
    $subject = stripslashes($_POST['subject']);
    $message = stripslashes($_POST['message']);
    $error = '';
    // Check name
    if (!$name) {
        $error .= 'Please enter your name.<br />';
    }
    // Check email
    if (!$email) {
        $error .= 'Please enter an e-mail address.<br />';
    }
    if ($email && !ValidateEmail($email)) {
        $error .= 'Please enter a valid e-mail address.<br />';
    }
    // Check message (length)
    if (!$message || strlen($message) < 10) {
        $error .= "Please enter your message. It should have at least 10 characters.<br />";
    }
    if (!$error) {
        $mail = new SendGrid\Mail();
        $mail->addTo('*****@*****.**')->setFrom($email)->setFromName($name)->setSubject($subject)->setText($message);
        if ($sendgrid->smtp->send($mail)) {
            echo 'OK';
        }
    } else {
        echo '<div class="notification_error">' . $error . '</div>';
    }
}
     * - Upload it to a web host and load mywebhost.com/sendnotifications.php 
     *   in a web browser.
     * - Download a local server like WAMP, MAMP or XAMPP. Point the web root 
     *   directory to the folder containing this file, and load 
     *   localhost:8888/sendnotifications.php in a web browser.
     */
    // Step 1: Download the Twilio-PHP library from twilio.com/docs/libraries,
    // and move it into the folder containing this file.
    require "Services/Twilio.php";
    // Step 2: set our AccountSid and AuthToken from www.twilio.com/user/account
    $AccountSid = "ACeca28c70e4a3d5d4bea2e1be2f608876";
    $AuthToken = "474465c0bacbb4f013c39ef1da106cc6";
    // Step 3: instantiate a new Twilio Rest Client
    $client = new Services_Twilio($AccountSid, $AuthToken);
    // Step 4: make an array of people we know, to send them a message.
    // Feel free to change/add your own phone number and name here.
    $people = array($phone => $name);
    // Step 5: Loop over all our friends. $number is a phone number above, and
    // $name is the name next to it
    foreach ($people as $number => $name) {
        $sms = $client->account->sms_messages->create("408-514-5160", $number, "Hey " . $name . ", " . $descript . "\n-From " . $user);
    }
}
include 'sendgrid-php-master/SendGrid_loader.php';
$sendgrid = new SendGrid('YeshRam', 'yeshrameshiscool');
$mail = new SendGrid\Mail();
$mail->addTo($email)->setFrom($yremail)->setSubject('Message From ' . $user . ' with TwilioAndSendgrid Script')->setText($descript)->setHtml('<strong>' . $descript . '</strong>');
$sendgrid->web->send($mail);
?>
	</body>
</html>