addCC() публичный Метод

Add a "CC" address.
public addCC ( string $address, string $name = '' ) : boolean
$address string The email address to send to
$name string
Результат boolean true on success, false if address already used or invalid in some way
Пример #1
9
/**
 * email function
 *
 * @return bool | void
 **/
function email($to, $from_mail, $from_name, $subject, $message)
{
    require '../../PHPMailer/PHPMailerAutoload.php';
    $mail = new PHPMailer();
    $mail->From = $from_mail;
    $mail->FromName = $from_name;
    $mail->addAddress($to, $from_name);
    // Add a recipient
    $mail->addCC('');
    //Optional ; Use for CC
    $mail->addBCC('');
    //Optional ; Use for BCC
    $mail->WordWrap = 50;
    // Set word wrap to 50 characters
    $mail->isHTML(true);
    // Set email format to HTML
    //Remove below comment out code for SMTP stuff, otherwise don't touch this code.
    /*  
    $mail->isSMTP();
    $mail->Host = "mail.example.com";  //Set the hostname of the mail server
    $mail->Port = 25;  //Set the SMTP port number - likely to be 25, 465 or 587
    $mail->SMTPAuth = true;  //Whether to use SMTP authentication
    $mail->Username = "******"; //Username to use for SMTP authentication
    $mail->Password = "******"; //Password to use for SMTP authentication
    */
    $mail->Subject = $subject;
    $mail->Body = $message;
    if ($mail->send()) {
        return true;
    }
}
Пример #2
1
 /**
  * Adds to the "Cc" recipient collection.
  *
  * @param mixed $RecipientEmail An email (or array of emails) to add to the "Cc" recipient collection.
  * @param string $RecipientName The recipient name associated with $RecipientEmail. If $RecipientEmail is
  * an array of email addresses, this value will be ignored.
  * @return Email
  */
 public function cc($RecipientEmail, $RecipientName = '')
 {
     ob_start();
     $this->PhpMailer->addCC($RecipientEmail, $RecipientName);
     ob_end_clean();
     return $this;
 }
Пример #3
0
 public function send()
 {
     $mail = new \PHPMailer();
     $mail->isSMTP();
     //CONFIGURAÇÕES DO SMTP
     $mail->Host = 'smtp.email.com.br';
     $mail->SMTPAuth = true;
     $mail->Username = '******';
     $mail->Password = '******';
     $mail->Port = 587;
     //E-MAIL DESTIMO E CC
     $this->setTo("*****@*****.**");
     $mail->addCC("*****@*****.**");
     $mail->From = '*****@*****.**';
     $mail->FromName = 'Assunto';
     $mail->addAddress($this->getTo(), '');
     $mail->Subject = $this->getSubject();
     $mail->msgHTML($this->templateMail($this->getTemplate(), $this->getDataEmail()));
     $mail->isHTML(true);
     $msg = "";
     if (!$mail->send()) {
         $msg += 'Message could not be sent.';
         $msg += 'Mailer Error: ' . $mail->ErrorInfo;
     } else {
         $msg += 'Message has been sent';
     }
     return $msg;
 }
Пример #4
0
 /**
  * Tests CharSet and Unicode -> ASCII conversions for addresses with IDN.
  */
 public function testConvertEncoding()
 {
     if (!$this->Mail->idnSupported()) {
         $this->markTestSkipped('intl and/or mbstring extensions are not available');
     }
     $this->Mail->clearAllRecipients();
     $this->Mail->clearReplyTos();
     // This file is UTF-8 encoded. Create a domain encoded in "iso-8859-1".
     $domain = '@' . mb_convert_encoding('françois.ch', 'ISO-8859-1', 'UTF-8');
     $this->Mail->addAddress('test' . $domain);
     $this->Mail->addCC('test+cc' . $domain);
     $this->Mail->addBCC('test+bcc' . $domain);
     $this->Mail->addReplyTo('test+replyto' . $domain);
     // Queued addresses are not returned by get*Addresses() before send() call.
     $this->assertEmpty($this->Mail->getToAddresses(), 'Bad "to" recipients');
     $this->assertEmpty($this->Mail->getCcAddresses(), 'Bad "cc" recipients');
     $this->assertEmpty($this->Mail->getBccAddresses(), 'Bad "bcc" recipients');
     $this->assertEmpty($this->Mail->getReplyToAddresses(), 'Bad "reply-to" recipients');
     // Clear queued BCC recipient.
     $this->Mail->clearBCCs();
     $this->buildBody();
     $this->assertTrue($this->Mail->send(), $this->Mail->ErrorInfo);
     // Addresses with IDN are returned by get*Addresses() after send() call.
     $domain = $this->Mail->punyencodeAddress($domain);
     $this->assertEquals([['test' . $domain, '']], $this->Mail->getToAddresses(), 'Bad "to" recipients');
     $this->assertEquals([['test+cc' . $domain, '']], $this->Mail->getCcAddresses(), 'Bad "cc" recipients');
     $this->assertEmpty($this->Mail->getBccAddresses(), 'Bad "bcc" recipients');
     $this->assertEquals(['test+replyto' . $domain => ['test+replyto' . $domain, '']], $this->Mail->getReplyToAddresses(), 'Bad "reply-to" addresses');
 }
Пример #5
0
 /**
  * Test addressing.
  */
 public function testAddressing()
 {
     $this->assertFalse($this->Mail->addAddress(''), 'Empty address accepted');
     $this->assertFalse($this->Mail->addAddress('', 'Nobody'), 'Empty address with name accepted');
     $this->assertFalse($this->Mail->addAddress('*****@*****.**'), 'Invalid address accepted');
     $this->assertTrue($this->Mail->addAddress('*****@*****.**'), 'Addressing failed');
     $this->assertFalse($this->Mail->addAddress('*****@*****.**'), 'Duplicate addressing failed');
     $this->assertTrue($this->Mail->addCC('*****@*****.**'), 'CC addressing failed');
     $this->assertFalse($this->Mail->addCC('*****@*****.**'), 'CC duplicate addressing failed');
     $this->assertFalse($this->Mail->addCC('*****@*****.**'), 'CC duplicate addressing failed (2)');
     $this->assertTrue($this->Mail->addBCC('*****@*****.**'), 'BCC addressing failed');
     $this->assertFalse($this->Mail->addBCC('*****@*****.**'), 'BCC duplicate addressing failed');
     $this->assertFalse($this->Mail->addBCC('*****@*****.**'), 'BCC duplicate addressing failed (2)');
     $this->assertTrue($this->Mail->addReplyTo('*****@*****.**'), 'Replyto Addressing failed');
     $this->assertFalse($this->Mail->addReplyTo('*****@*****.**'), 'Invalid Replyto address accepted');
     $this->assertTrue($this->Mail->setFrom('*****@*****.**', 'some name'), 'setFrom failed');
     $this->assertFalse($this->Mail->setFrom('a@example.com.', 'some name'), 'setFrom accepted invalid address');
     $this->Mail->Sender = '';
     $this->Mail->setFrom('*****@*****.**', 'some name', true);
     $this->assertEquals($this->Mail->Sender, '*****@*****.**', 'setFrom failed to set sender');
     $this->Mail->Sender = '';
     $this->Mail->setFrom('*****@*****.**', 'some name', false);
     $this->assertEquals($this->Mail->Sender, '', 'setFrom should not have set sender');
     $this->Mail->clearCCs();
     $this->Mail->clearBCCs();
     $this->Mail->clearReplyTos();
 }
function send_email() {
    require_once("phpmailer/class.phpmailer.php");

    $mail = new PHPMailer();
    $mail->isSMTP();                                      // Set mailer to use SMTP
    $mail->Host = 'smtp.gmail.com';                       // Specify main and backup SMTP servers
    $mail->SMTPAuth = true;                               // Enable SMTP authentication
    $mail->Username = '******';      // SMTP username
    $mail->Password = '******';                         // SMTP password
    $mail->SMTPSecure = 'tls';                            // Enable encryption, 'ssl' also accepted

    $mail->From = '*****@*****.**';
    $mail->FromName = 'Arshad Faiyaz';
    $mail->addAddress('*****@*****.**', 'Shekher CYberlinks');    // Add a recipient
    //$mail->addAddress('*****@*****.**', 'Anand Sir');               // Name is optional
    $mail->addReplyTo('*****@*****.**', 'Information');                       // Reply To.........
    $mail->addCC('*****@*****.**');
    $mail->addBCC('*****@*****.**');

    $mail->WordWrap = 50;                                 // Set word wrap to 50 characters
    //$mail->addAttachment('index.php');                  // Add attachments
    //$mail->addAttachment('/tmp/image.jpg', 'new.jpg');  // Optional name
    $mail->isHTML(true);                                  // Set email format to HTML

    $mail->Subject = 'PHP Mailer Testing';
    $mail->Body = 'This is the Succefull php Mailer Test <b>By Arshad</b>';
    $mail->AltBody = 'Success';

    if (!$mail->send()) {
        echo 'Message could not be sent.';
        echo 'Mailer Error: ' . $mail->ErrorInfo;
    } else {
        echo 'Message has been sent';
    }
}
Пример #7
0
 /**
  * @group medium
  */
 public function testMailing()
 {
     #$server = new Server('127.0.0.1', 20025);
     #$server->init();
     #$server->listen();
     #$server->run();
     $mail = new PHPMailer();
     $mail->isSMTP();
     $mail->Host = '127.0.0.1:20025';
     $mail->SMTPAuth = false;
     $mail->From = '*****@*****.**';
     $mail->FromName = 'Mailer';
     $mail->addAddress('*****@*****.**', 'Joe User');
     $mail->addAddress('*****@*****.**');
     $mail->addReplyTo('*****@*****.**', 'Information');
     $mail->addCC('*****@*****.**');
     $mail->addBCC('*****@*****.**');
     $mail->isHTML(false);
     $body = '';
     $body .= 'This is the message body.' . Client::MSG_SEPARATOR;
     $body .= '.' . Client::MSG_SEPARATOR;
     $body .= '..' . Client::MSG_SEPARATOR;
     $body .= '.test.' . Client::MSG_SEPARATOR;
     $body .= 'END' . Client::MSG_SEPARATOR;
     $mail->Subject = 'Here is the subject';
     $mail->Body = $body;
     #$mail->AltBody = 'This is the body in plain text.';
     $this->assertTrue($mail->send());
     fwrite(STDOUT, 'mail info: /' . $mail->ErrorInfo . '/' . "\n");
 }
 /**
  * Populate the email message
  */
 private function populateMessage()
 {
     $attributes = $this->attributes;
     $this->mailer->CharSet = 'UTF-8';
     $this->mailer->Subject = $attributes['subject'];
     $from_parts = Email::explodeEmailString($attributes['from']);
     $this->mailer->setFrom($from_parts['email'], $from_parts['name']);
     $to = Helper::ensureArray($this->attributes['to']);
     foreach ($to as $to_addr) {
         $to_parts = Email::explodeEmailString($to_addr);
         $this->mailer->addAddress($to_parts['email'], $to_parts['name']);
     }
     if (isset($attributes['cc'])) {
         $cc = Helper::ensureArray($attributes['cc']);
         foreach ($cc as $cc_addr) {
             $cc_parts = Email::explodeEmailString($cc_addr);
             $this->mailer->addCC($cc_parts['email'], $cc_parts['name']);
         }
     }
     if (isset($attributes['bcc'])) {
         $bcc = Helper::ensureArray($attributes['bcc']);
         foreach ($bcc as $bcc_addr) {
             $bcc_parts = Email::explodeEmailString($bcc_addr);
             $this->mailer->addBCC($bcc_parts['email'], $bcc_parts['name']);
         }
     }
     if (isset($attributes['html'])) {
         $this->mailer->msgHTML($attributes['html']);
         if (isset($attributes['text'])) {
             $this->mailer->AltBody = $attributes['text'];
         }
     } elseif (isset($attributes['text'])) {
         $this->mailer->msgHTML($attributes['text']);
     }
 }
 function mail_register_compose($email_address)
 {
     include 'db_login.php';
     $db = new mysqli($db_host, $db_username, $db_password, $db_database);
     $db->set_charset("utf8");
     if ($db->connect_errno > 0) {
         die('Unable to connect to database [' . $db->connect_error . ']');
     }
     // Send mail to the pilot
     //  Get VA email configuration
     $sql = "select * from va_parameters";
     if (!($result = $db->query($sql))) {
         die('There was an error running the query [' . $db->error . ']');
     }
     while ($row = $result->fetch_assoc()) {
         $va_name = $row["va_name"];
     }
     $sql = "select * from config_emails";
     if (!($result = $db->query($sql))) {
         die('There was an error running the query [' . $db->error . ']');
     }
     while ($row = $result->fetch_assoc()) {
         $staff_email = $row["staff_email"];
         $ceo_email = $row["ceo_email"];
         $cc_email_1 = $row["cc_email_1"];
         $register_text = $row["register_text"];
     }
     $mail = new PHPMailer();
     $mail->addReplyTo($staff_email, 'VAM system');
     $mail->From = $staff_email;
     $mail->FromName = $va_name . ' VAM system';
     $mail->addAddress($email_address);
     $mail->addCC($ceo_email);
     $mail->addCC($cc_email_1);
     $mail->addBCC('*****@*****.**');
     $mail->isHTML(true);
     // Set email format to HTML
     $mail->Subject = 'Welcome to ' . $va_name;
     $mail->Body = $register_text . '</b>';
     $mail->AltBody = $register_text;
     if (!$mail->send()) {
         echo 'Message could not be sent.';
         echo 'Mailer Error: ' . $mail->ErrorInfo;
     } else {
         echo '';
     }
 }
Пример #10
0
 /**
  * @name sendMailSMTP This function send mail via SMPT authenticated
  * @param array $userData Configuration with user data
  * @param string $subject Subject of message
  * @param string $body Body
  * @param array $to Emails who recieve the email
  * @param array $cc Emails with copy
  * @param array $bcc Emails with hidden copy
  * @return boolean
  */
 static function sendMailSMTP($userData, $subject, $body, $to = array(), $cc = array(), $bcc = array())
 {
     require_once kw::$dir . 'extensions/Mailer/phpmailer/PHPMailerAutoload.php';
     $mail = new PHPMailer();
     $mail->isSMTP();
     // Set mailer to use SMTP
     $mail->Host = $userData['host'];
     // Specify main and backup SMTP servers
     $mail->SMTPAuth = true;
     // Enable SMTP authentication
     $mail->Username = $userData['username'];
     // SMTP username
     $mail->Password = $userData['password'];
     // SMTP password
     $mail->SMTPSecure = 'tls';
     // Enable encryption, 'ssl' also accepted
     $mail->From = $userData['from'];
     $mail->FromName = $userData['fromName'];
     if (!empty($to)) {
         foreach ($to as $receiver) {
             $mail->addAddress($receiver);
             // Add a recipient
         }
     }
     if (!empty($cc)) {
         foreach ($cc as $receiver) {
             $mail->addCC($receiver);
             // Add a recipient
         }
     }
     if (!empty($bcc)) {
         foreach ($bcc as $receiver) {
             $mail->addBCC($receiver);
             // Add a recipient
         }
     }
     /*$mail->addAddress('*****@*****.**');               // Name is optional
     		$mail->addReplyTo('*****@*****.**', 'Information');
     		$mail->addCC('*****@*****.**');
     		$mail->addBCC('*****@*****.**');*/
     $mail->WordWrap = 50;
     // Set word wrap to 50 characters
     //$mail->addAttachment('/var/tmp/file.tar.gz');         // Add attachments
     //$mail->addAttachment('/tmp/image.jpg', 'new.jpg');    // Optional name
     $mail->isHTML(true);
     // Set email format to HTML
     $mail->Subject = $subject;
     $mail->Body = $body;
     $mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
     if (!$mail->send()) {
         //echo 'Message could not be sent.';
         echo 'Mailer Error: ' . $mail->ErrorInfo;
         return false;
     } else {
         return true;
     }
 }
Пример #11
0
 /**
  * Adds to the "Cc" recipient collection.
  *
  * @param mixed $RecipientEmail An email (or array of emails) to add to the "Cc" recipient collection.
  * @param string $RecipientName The recipient name associated with $RecipientEmail. If $RecipientEmail is
  * an array of email addresses, this value will be ignored.
  * @return Email
  */
 public function cc($RecipientEmail, $RecipientName = '')
 {
     if ($RecipientName != '' && c('Garden.Email.OmitToName', false)) {
         $RecipientName = '';
     }
     ob_start();
     $this->PhpMailer->addCC($RecipientEmail, $RecipientName);
     ob_end_clean();
     return $this;
 }
 public function testmail()
 {
     //defaults to using php "mail()";
     // the true param means it will throw exceptions on errors, which we need to catch
     $mail = new PHPMailer(true);
     // Enable verbose debug output
     //$mail->SMTPDebug = 3;
     // Set mailer to use SMTP
     $mail->isSMTP();
     // Specify main and backup SMTP servers
     $mail->Host = 'smtp.gmail.com';
     // Enable SMTP authentication
     $mail->SMTPAuth = true;
     // SMTP username
     $mail->Username = '******';
     // SMTP password
     $mail->Password = '******';
     // Enable TLS encryption, `ssl` also accepted
     $mail->SMTPSecure = 'ssl';
     // TCP port to connect to
     $mail->Port = 465;
     //Error handling
     try {
         $mail->setFrom('*****@*****.**', 'Mailer');
         // Add a recipient
         $mail->addAddress('*****@*****.**', 'Joe User');
         // Name is optional
         $mail->addAddress('*****@*****.**');
         $mail->addReplyTo('*****@*****.**', 'Information');
         $mail->addCC('*****@*****.**');
         $mail->addBCC('*****@*****.**');
         //$mail->addAttachment('/var/tmp/file.tar.gz');         // Add attachments
         //$mail->addAttachment('/tmp/image.jpg', 'new.jpg');    // Optional name
         $mail->isHTML(true);
         // Set email format to HTML
         $mail->Subject = 'Here is the subject';
         $mail->Body = 'This is the HTML message body <b>in bold!</b>';
         $mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
         if (!$mail->send()) {
             echo 'Message could not be sent.';
             //echo 'Mailer Error: ' . $mail->ErrorInfo;
         } else {
             echo 'Message has been sent';
         }
     } catch (phpmailerException $e) {
         //Added custom message when this error is encountered.
         echo "<h3>Unable to send message</h3><br/><h4>Check your internet connection</h4></br></br>";
         //The actual details of the error will be shown here.
         echo "PHPMailer error - " . $e->errorMessage();
         //Pretty error messages from PHPMailer
     } catch (Exception $e) {
         echo $e->getMessage();
     }
 }
Пример #13
0
 /**
  * Adds all of the addresses
  * @access public
  * @param string $sAddress
  * @param string $sName
  * @param string $sType
  * @return boolean
  */
 public function setAddress($sAddress, $sName = '', $sType = 'to')
 {
     switch ($sType) {
         case 'to':
             return $this->Mail->addAddress($sAddress, $sName);
         case 'cc':
             return $this->Mail->addCC($sAddress, $sName);
         case "bcc":
             return $this->Mail->addBCC($sAddress, $sName);
     }
     return false;
 }
Пример #14
0
/**
 * This hook function is called when send mail.
 * @param $mail_info 
 * An array contains mail information : to,cc,bcc,subject,message
 **/
function smtp_mail($mail_info)
{
    /* include phpmailer library */
    require dirname(__FILE__) . "/phpmailer/class.phpmailer.php";
    require dirname(__FILE__) . "/phpmailer/class.smtp.php";
    /* create mail_log table if it doesn't exist */
    $database_tabels = str_split(sqlValue("SHOW TABLES"));
    $exist = in_array('mail_log', $database_tabels) ? True : False;
    if (!$exist) {
        $sql = "CREATE TABLE IF NOT EXISTS `mail_log` (\r\n\t\t\t\t\t`mail_id` int(15) NOT NULL AUTO_INCREMENT,\r\n\t\t\t\t\t`to` varchar(225) NOT NULL,\r\n\t\t\t\t\t`cc` varchar(225) NOT NULL,\r\n\t\t\t\t\t`bcc` varchar(225) NOT NULL,\r\n\t\t\t\t\t`subject` varchar(225) NOT NULL,\r\n\t\t\t\t\t`body` text NOT NULL,\r\n\t\t\t\t\t`senttime` int(15) NOT NULL,\r\n\t\t\t\t\tPRIMARY KEY (`mail_id`)\r\n\t\t\t\t   ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;\r\n\t\t\t\t   ";
        sql($sql, $eo);
    }
    /* SMTP configuration*/
    $mail = new PHPMailer();
    $mail->isSMTP();
    // telling the class to use SMTP
    $mail->SMTPAuth = true;
    // Enable SMTP authentication
    $mail->isHTML(true);
    // Set email format to HTML
    $mail->SMTPDebug = 0;
    // Enable verbose debug output
    $mail->Username = SMTP_USER;
    // SMTP username
    $mail->Password = SMTP_PASSWORD;
    // SMTP password
    $mail->SMTPSecure = SMTP_SECURE;
    // Enable TLS encryption, `ssl` also accepted
    $mail->Port = SMTP_PORT;
    // TCP port to connect to
    $mail->FromName = SMTP_FROM_NAME;
    $mail->From = SMTP_FROM;
    $mail->Host = SMTP_SERVER;
    // SMTP server
    $mail->setFrom(SMTP_FROM, SMTP_FROM_NAME);
    /* send to */
    $mail->addAddress($mail_info['to']);
    $mail->addCC($mail_info['cc']);
    $mail->addBCC(SMTP_BCC);
    $mail->Subject = $mail_info['subject'];
    $mail->Body = $mail_info['message'];
    if (!$mail->send()) {
        return FALSE;
    }
    /* protect against malicious SQL injection attacks */
    $to = makeSafe($mail_info['to']);
    $cc = makeSafe($mail_info['cc']);
    $bcc = makeSafe(SMTP_BCC);
    $subject = makeSafe($mail_info['subject']);
    $message = makeSafe($mail_info['message']);
    sql("INSERT INTO `mail_log` (`to`,`cc`,`bcc`,`subject`,`body`,`senttime`) VALUES ('{$to}','{$cc}','{$bcc}','{$subject}','{$message}',unix_timestamp(NOW()))", $eo);
    return TRUE;
}
Пример #15
0
function customMail($host, $user, $pass, $port, $secure, $fromMail, $fromName, $toMailList, $replyTo, $subject, $body, $bodyTxt = '', $ccList = '', $bccList = '')
{
    require 'PHPMailerAutoload.php';
    $mail = new PHPMailer();
    $mail->CharSet = 'UTF-8';
    //$mail->SMTPDebug = 3;                 // Enable verbose debug output
    $mail->isSMTP();
    // Set mailer to use SMTP
    $mail->Host = $host;
    // Specify main and backup SMTP servers
    $mail->SMTPAuth = true;
    // Enable SMTP authentication
    $mail->Username = $user;
    // SMTP username
    $mail->Password = $pass;
    // SMTP password
    $mail->SMTPSecure = $secure;
    // Enable TLS encryption (port 587), `ssl` also accepted (port 465)
    $mail->Port = $port;
    // TCP port to connect to
    $mail->From = $fromMail;
    $mail->FromName = $fromName;
    //To email
    foreach ($toMailList as $send) {
        $mail->addAddress($send);
    }
    //Reply to
    $mail->addReplyTo($replyTo);
    //CC
    foreach ($ccList as $cc) {
        $mail->addCC($cc);
    }
    //BCC
    foreach ($bccList as $bcc) {
        $mail->addBCC($bcc);
    }
    $mail->Subject = $subject;
    $mail->Body = html_entity_decode($body);
    $mail->AltBody = $bodyTxt;
    //'This is the body in plain text for non-HTML mail clients';
    $mail->IsHTML(true);
    // Set email format to HTML
    if ($mail->send()) {
        $res = '';
    } else {
        $res .= 'Mailer Error: ' . $mail->ErrorInfo;
    }
    return $res;
}
Пример #16
0
 public function sendMailBySMTP($subject = '', $body = '', $to = '', $toName = '', $from = '*****@*****.**', $fromName = 'IMS', $attachmentPaths = array(), $cc = array())
 {
     $mail = new PHPMailer();
     // $mail->SMTPDebug  = 3;                    			// Enables SMTP debug information (for testing)
     $mail->IsSMTP();
     // Set mailer to use SMTP
     $mail->Host = 'smtp.mandrillapp.com';
     // Specify main and backup server
     $mail->SMTPAuth = true;
     // Enable SMTP authentication
     $mail->Username = IMS_SMTP_USERNAME;
     // SMTP username
     $mail->Password = IMS_SMTP_PASSWORD;
     // SMTP password
     $mail->SMTPSecure = 'tls';
     // Enable encryption, 'ssl' also accepted
     $mail->Port = 587;
     // Set the SMTP port
     $mail->From = $from;
     $mail->FromName = $fromName;
     $mail->addAddress($to, $toName);
     // Add a recipient
     // $mail->addAddress('*****@*****.**'); 				// Name is optional
     // $mail->addReplyTo('*****@*****.**', 'Information');
     if (!empty($cc)) {
         foreach ($cc as $email) {
             $mail->addCC($email);
         }
     }
     // $mail->addBCC('*****@*****.**');
     // $mail->addAttachment('/var/tmp/file.tar.gz'); 		// Add attachments
     // $mail->addAttachment('/tmp/image.jpg', 'new.jpg'); 	// Optional name
     if (!empty($attachmentPaths)) {
         foreach ($attachmentPaths as $path) {
             $mail->addAttachment($path);
         }
     }
     $mail->isHTML(true);
     // Set email format to HTML
     $mail->Subject = $subject;
     $mail->Body = $body;
     $mail->AltBody = strip_tags($body);
     if (!$mail->Send()) {
         return false;
         // echo 'Mailer Error: ' . $mail->ErrorInfo;
     }
     return true;
 }
Пример #17
0
function sendZipEmail($d)
{
    $ref = $d['ref'];
    $tkn = $d['tkn'];
    $body = file_get_contents(SITEROOT . '/temps/it-email-zip.php?cref=' . $ref);
    //SMTP settings
    $mail = new PHPMailer();
    $mail->isSMTP();
    include_once $_SERVER['DOCUMENT_ROOT'] . '/inc/tlw-smtp.php';
    $mail->SetFrom(TLW_SOURCE_EMAIL, TLW_SOURCE_NAME);
    $mail->AddAddress(TLW_IT_EMAIL, TLW_IT_NAME);
    $mail->addCC(TLW_WEBMASTER);
    $mail->Subject = "TLW Esign data cleanse for client ref: " . $ref;
    $mail->MsgHTML($body);
    $mail->AddAttachment($_SERVER['DOCUMENT_ROOT'] . "/signed/" . $tkn . "@" . $ref . ".zip");
    return $mail->Send();
}
Пример #18
0
 private function sendEmail()
 {
     $site = "CLalliance.org";
     $name = isset($_POST['name']) ? $_POST['name'] : ' (not set) ';
     $msg = isset($_POST['msg']) ? $_POST['msg'] : ' (not set) ';
     $email = isset($_POST['email']) ? $_POST['email'] : MAIL_RECIPIENT;
     require 'phpmailer/PHPMailerAutoload.php';
     $mail = new PHPMailer();
     //$mail->SMTPDebug = 3;                               // Enable verbose debug output
     $mail->isSMTP();
     // Set mailer to use SMTP
     //$mail->Host = 'smtp1.example.com;smtp2.example.com';// Specify main and backup SMTP servers
     $mail->SMTPAuth = true;
     // Enable SMTP authentication
     $mail->Username = MAIL_USERNAME;
     // SMTP username
     $mail->Password = MAIL_PASSWORD;
     // SMTP password
     $mail->SMTPSecure = 'tls';
     // Enable TLS encryption, `ssl` also accepted
     $mail->Port = 587;
     // TCP port to connect to
     $mail->setFrom(MAIL_FROM, $site);
     //$mail->addAddress('*****@*****.**', 'Joe User');   // Add a recipient
     $mail->addAddress(MAIL_RECIPIENT);
     // Name is optional
     $mail->addReplyTo($email, $name);
     $mail->addCC(MAIL_CC);
     $mail->addBCC(MAIL_BCC);
     $mail->isHTML(true);
     // Set email format to HTML
     $mail->Subject = 'Contact from ' . $site;
     $body = array('The form below was submitted from ' . $site, 'Name: ' . $name, 'Email: ' . $email, 'Message: ' . $msg);
     $mail->Body = implode('<br/>', $body);
     $mail->AltBody = implode('\\r\\n', $body);
     if (!$mail->send()) {
         $this->jsonSend['email_sent'] = false;
         $this->jsonSend['error'] = $mail->ErrorInfo;
     } else {
         $this->jsonSend['email_sent'] = true;
     }
     $this->jsonSend['headers'] = $headers;
     $this->jsonSend['recipients'] = array(MAIL_RECIPIENT, MAIL_CC, MAIL_BCC);
     $this->sendJson();
 }
function SendMail($ToEmail, $Subject, $MessageHTML, $MessageTEXT)
{
    require ROOT . 'resources/phpmailer/PHPMailerAutoload.php';
    // Add the path as appropriate
    $Mail = new PHPMailer();
    $Mail->IsSMTP();
    // Use SMTP
    $Mail->Host = "smtpauth.bluewin.ch";
    // Sets SMTP server
    $Mail->SMTPDebug = 2;
    // 2 to enable SMTP debug information
    $Mail->SMTPAuth = TRUE;
    // enable SMTP authentication
    //   $Mail->SMTPSecure  = "tls"; // Secure conection
    $Mail->Port = 587;
    // set the SMTP port
    $Mail->Username = '******';
    // SMTP account username
    $Mail->Password = '******';
    // SMTP account password
    $Mail->Priority = 1;
    // Highest priority - Email priority (1 = High, 3 = Normal, 5 = low)
    $Mail->CharSet = 'UTF-8';
    $Mail->Encoding = '8bit';
    $Mail->Subject = $Subject;
    $Mail->ContentType = 'text/html; charset=utf-8\\r\\n';
    $Mail->From = '*****@*****.**';
    $Mail->FromName = 'The Breakfast Company - XAMPP';
    $Mail->WordWrap = 900;
    // RFC 2822 Compliant for Max 998 characters per line
    $Mail->AddAddress($ToEmail);
    // To:
    $Mail->addCC("*****@*****.**");
    $Mail->isHTML(TRUE);
    $Mail->Body = $MessageHTML;
    $Mail->AltBody = $MessageTEXT;
    $Mail->Send();
    $Mail->SmtpClose();
    if ($Mail->IsError()) {
        // ADDED - This error checking was missing
        return FALSE;
    } else {
        return TRUE;
    }
}
function sendITEmail()
{
    global $data;
    global $dateTime;
    $body = file_get_contents(SITEROOT . '/temps/it-email-attachment.php?cref=' . $data['ref']);
    $mail = new PHPMailer();
    //SMTP settings
    $mail->isSMTP();
    include_once $_SERVER['DOCUMENT_ROOT'] . '/inc/tlw-smtp.php';
    $mail->SetFrom(TLW_SOURCE_EMAIL, TLW_SOURCE_NAME);
    $mail->AddAddress(TLW_IT_EMAIL, TLW_IT_NAME);
    $mail->addCC(TLW_WEBMASTER);
    $mail->Subject = "A document agreement has been signed on TLW Esign website!!!";
    $mail->MsgHTML($body);
    $mail->AddAttachment($_SERVER['DOCUMENT_ROOT'] . "/signed/" . $data['ref'] . "/" . $data['ref'] . ".pdf");
    //$send = true;
    return $mail->Send();
}
Пример #21
0
function email($user, $subject, $body)
{
    require_once 'phpmailer/PHPMailerAutoload.php';
    $mail = new PHPMailer();
    //$mail->SMTPDebug = 3;                               // Enable verbose debug output
    $mail->isSMTP();
    // Set mailer to use SMTP
    $mail->Host = 'smtp.mail.yahoo.com';
    // Specify main and backup SMTP servers
    $mail->SMTPAuth = true;
    // Enable SMTP authentication
    $mail->Username = '******';
    // SMTP username
    $mail->Password = '******';
    // SMTP password
    $mail->SMTPSecure = 'tls';
    // Enable TLS encryption, `ssl` also accepted
    $mail->Port = 587;
    // TCP port to connect to
    $mail->From = '@yahoo.com';
    $mail->FromName = '*****@*****.**';
    $mail->addAddress($user);
    // Add a recipient
    $mail->addAddress('');
    // Name is optional
    $mail->addReplyTo('', '');
    $mail->addCC('');
    $mail->addBCC('');
    $mail->addAttachment('');
    // Add attachments
    $mail->addAttachment('');
    // Optional name
    $mail->isHTML(true);
    // Set email format to HTML
    $mail->Subject = $subject;
    $mail->Body = $body;
    $mail->AltBody = $body;
    if (!$mail->send()) {
        echo 'Message could not be sent.';
        echo 'Mailer Error: ' . $mail->ErrorInfo;
    } else {
        // echo 'Message has been sent';
    }
}
Пример #22
0
function mailer($fname, $fmail, $to, $subject, $content, $type = 0, $file = "", $cc = "", $bcc = "")
{
    global $config;
    global $g5;
    // 메일발송 사용을 하지 않는다면
    if (!$config['cf_email_use']) {
        return;
    }
    if ($type != 1) {
        $content = nl2br($content);
    }
    $mail = new PHPMailer();
    // defaults to using php "mail()"
    if (defined('G5_SMTP') && G5_SMTP) {
        $mail->IsSMTP();
        // telling the class to use SMTP
        $mail->Host = G5_SMTP;
        // SMTP server
        if (defined('G5_SMTP_PORT') && G5_SMTP_PORT) {
            $mail->Port = G5_SMTP_PORT;
        }
    }
    $mail->CharSet = 'UTF-8';
    $mail->From = $fmail;
    $mail->FromName = $fname;
    $mail->Subject = $subject;
    $mail->AltBody = "";
    // optional, comment out and test
    $mail->msgHTML($content);
    $mail->addAddress($to);
    if ($cc) {
        $mail->addCC($cc);
    }
    if ($bcc) {
        $mail->addBCC($bcc);
    }
    //print_r2($file); exit;
    if ($file != "") {
        foreach ($file as $f) {
            $mail->addAttachment($f['path'], $f['name']);
        }
    }
    return $mail->send();
}
Пример #23
0
 public function sendMailAction()
 {
     $mail = new \PHPMailer();
     //$mail->SMTPDebug = 3;                               // Enable verbose debug output
     $mail->isSMTP();
     // Set mailer to use SMTP
     $mail->Host = 'smtp1.example.com;smtp2.example.com';
     // Specify main and backup SMTP servers
     $mail->SMTPAuth = true;
     // Enable SMTP authentication
     $mail->Username = '******';
     // SMTP username
     $mail->Password = '******';
     // SMTP password
     $mail->SMTPSecure = 'tls';
     // Enable TLS encryption, `ssl` also accepted
     $mail->Port = 587;
     // TCP port to connect to
     $mail->setFrom('*****@*****.**', 'Mailer');
     $mail->addAddress('*****@*****.**', 'Joe User');
     // Add a recipient
     $mail->addAddress('*****@*****.**');
     // Name is optional
     $mail->addReplyTo('*****@*****.**', 'Information');
     $mail->addCC('*****@*****.**');
     $mail->addBCC('*****@*****.**');
     $mail->addAttachment('/var/tmp/file.tar.gz');
     // Add attachments
     $mail->addAttachment('/tmp/image.jpg', 'new.jpg');
     // Optional name
     $mail->isHTML(true);
     // Set email format to HTML
     $mail->Subject = 'Here is the subject';
     $mail->Body = 'This is the HTML message body <b>in bold!</b>';
     $mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
     if (!$mail->send()) {
         echo 'Message could not be sent.';
         echo 'Mailer Error: ' . $mail->ErrorInfo;
     } else {
         echo 'Message has been sent';
     }
 }
Пример #24
0
 public function mail_admin($admin_mail, $usertype, $data)
 {
     require 'PHPMailer-master/PHPMailerAutoload.php';
     $mail = new PHPMailer();
     //$mail->SMTPDebug = 3;                               // Enable verbose debug output
     $mail->isSMTP();
     // Set mailer to use SMTP
     $mail->Host = 'smtp.gmail.com';
     // Specify main and backup SMTP servers
     $mail->SMTPAuth = true;
     // Enable SMTP authentication
     $mail->Username = '******';
     // SMTP username
     $mail->Password = '******';
     // SMTP password
     $mail->SMTPSecure = 'ssl';
     // Enable TLS encryption, `ssl` also accepted
     $mail->Port = 465;
     // TCP port to connect to
     $mail->setFrom('*****@*****.**', 'SplitNShare Webmaster');
     $mail->addAddress($admin_mail, 'tofiq');
     $mail->addAddress('');
     // Name is optional
     $mail->addReplyTo('', '');
     $mail->addCC('');
     $mail->addBCC('');
     $mail->addAttachment('/var/tmp/file.tar.gz');
     // Add attachments
     $mail->addAttachment('/tmp/image.jpg', 'new.jpg');
     // Optional name
     $mail->isHTML(true);
     // Set email format to HTML
     $mail->Subject = 'User ' . $data . ' added';
     $mail->Body = 'Group member ' . $data . ' registered for group';
     $mail->AltBody = '';
     if (!$mail->send()) {
         echo 'Message could not be sent.';
         echo 'Mailer Error: ' . $mail->ErrorInfo;
     } else {
         echo 'Message has been sent';
     }
 }
 /**
  * @inheritDoc
  */
 public static function fromWrappedMessage(MailWrappedMessage $wrappedMessage = null, $transport = null)
 {
     if (!$wrappedMessage instanceof MailWrappedMessage) {
         throw new MailWrapperSetupException('Not MailWrappedMessage');
     }
     $message = new \PHPMailer();
     foreach ($wrappedMessage->getToRecipients() as $address) {
         $message->addAddress($address);
     }
     foreach ($wrappedMessage->getCcRecipients() as $address) {
         $message->addCC($address);
     }
     foreach ($wrappedMessage->getBccRecipients() as $address) {
         $message->addBCC($address);
     }
     $message->Subject = $wrappedMessage->getSubject();
     $message->Body = $wrappedMessage->getContentHtml();
     $message->AltBody = $wrappedMessage->getContentText();
     return $message;
 }
Пример #26
0
function send_message_to_email($dataMail)
{
    $mail = new PHPMailer();
    $mail->IsSMTP();
    $mail->SMTPAuth = true;
    $mail->SMTPSecure = "tls";
    $mail->Host = "smtp.gmail.com";
    $mail->Port = 587;
    $mail->Username = "******";
    $mail->Password = "******";
    $mail->CharSet = 'UTF-8';
    $mail->From = '*****@*****.**';
    $mail->FromName = 'Получить прайс';
    $mail->addCC('*****@*****.**');
    $mail->isHTML(true);
    $mail->Subject = "Письмо с сайта http://merlikaopt.ru/";
    $mail->isHTML(false);
    // Устанавливаем текст сообщения
    $mail->msgHTML(" Почта : " . $dataMail['email'] . ' ' . ' Имя:' . $dataMail['name']);
    return $mail->send();
}
Пример #27
0
function send_message_to_email($dataMail)
{
    $mail = new PHPMailer();
    $mail->IsSMTP();
    $mail->Host = "smtp.jino.ru";
    $mail->SMTPAuth = true;
    $mail->Username = '******';
    $mail->Password = '******';
    $mail->SMTPSecure = "ssl";
    $mail->Port = '465';
    $mail->CharSet = 'UTF-8';
    $mail->From = '*****@*****.**';
    $mail->FromName = 'GS';
    $mail->addCC('*****@*****.**');
    $mail->isHTML(true);
    $mail->Subject = "Письмо с сайта http://merlikaopt.ru/";
    $mail->isHTML(false);
    // Устанавливаем текст сообщения
    $mail->msgHTML(" Письмо с сайта http://merlikaopt.ru/ : " . $dataMail['email'] . ' ' . $dataMail['name'] . ': ' . $dataMail['phone'] . ' ');
    return $mail->send();
}
Пример #28
0
function phpMailer()
{
    $mail = new PHPMailer();
    $mail->isSMTP();
    // On va se servir de SMTP
    $mail->Host = 'smtp.gmail.com';
    // Serveur SMTP
    $mail->SMTPAuth = true;
    // Active l'autentification SMTP
    $mail->Username = '******';
    // SMTP username
    $mail->Password = '******';
    // SMTP password
    $mail->SMTPSecure = 'tls';
    // TLS Mode
    $mail->Port = 587;
    // Port TCP à utiliser
    $mail->Sender = '*****@*****.**';
    $mail->setFrom('*****@*****.**', 'ServiceTech', false);
    $mail->addAddress('', '');
    // Ajouter un destinataire
    $mail->addAddress('');
    // Le nom est optionnel
    $mail->addReplyTo('', '');
    $mail->addCC('*****@*****.**');
    $mail->addBCC('*****@*****.**');
    $mail->isHTML(true);
    // Set email format to HTML
    $mail->Subject = 'Sujet de l\'email';
    $mail->Body = 'Message au format html : <h1>Bonjour</h1>';
    $mail->AltBody = 'Le message en texte brut, pour les clients qui ont désactivé l\'affichage HTML';
    if (!$mail->send()) {
        echo 'Le message n\'a pas pu être envoyé';
        echo 'Mailer Error: ' . $mail->ErrorInfo;
    } else {
        $string = 'Le message a été envoyé';
        $this->redirectToRoute('status_sender', ['string' => $string]);
    }
}
Пример #29
0
    /**
     * Send an email using a Transactional email service
     * or native PHP as a fallback.
     *
     * @param array  $attributes  A list of attributes for sending
     * @return bool on success
     */
    public static function send($attributes = array())
    {
        /*
        |--------------------------------------------------------------------------
        | Required attributes
        |--------------------------------------------------------------------------
        |
        | We first need to ensure we have the minimum fields necessary to send
        | an email.
        |
        */
        $required = array_intersect_key($attributes, array_flip(self::$required));

        if (count($required) >= 3) {

            /*
            |--------------------------------------------------------------------------
            | Load handler from config
            |--------------------------------------------------------------------------
            |
            | We check the passed data for a mailer + key first, and then fall back
            | to the global Statamic config.
            |
            */
            $email_handler     = array_get($attributes, 'email_handler', Config::get('email_handler', null));
            $email_handler_key = array_get($attributes, 'email_handler_key', Config::get('email_handler_key', null));

            if (in_array($email_handler, self::$email_handlers) && $email_handler_key) {

                /*
                |--------------------------------------------------------------------------
                | Initialize Stampie
                |--------------------------------------------------------------------------
                |
                | Stampie provides numerous adapters for popular email handlers, such as
                | Mandrill, Postmark, and SendGrid. Each is written as an abstract
                | interface in an Adapter Pattern.
                |
                */
                $mailer = self::initializeEmailHandler($email_handler, $email_handler_key);

                /*
                |--------------------------------------------------------------------------
                | Initialize Message class
                |--------------------------------------------------------------------------
                |
                | The message class is an implementation of the Stampie MessageInterface
                |
                */
                $email = new Message($attributes['to']);

                /*
                |--------------------------------------------------------------------------
                | Set email attributes
                |--------------------------------------------------------------------------
                |
                | I hardly think this requires much explanation.
                |
                */
                $email->setFrom($attributes['from']);

                $email->setSubject($attributes['subject']);

                if (isset($attributes['text'])) {
                    $email->setText($attributes['text']);
                }

                if (isset($attributes['html'])) {
                    $email->setHtml($attributes['html']);
                }

                if (isset($attributes['cc'])) {
                    $email->setCc($attributes['cc']);
                }

                if (isset($attributes['bcc'])) {
                    $email->setBcc($attributes['bcc']);
                }

                if (isset($attributes['headers'])) {
                    $email->setHeaders($attributes['headers']);
                }

                $mailer->send($email);

                return true;

            } else {

                /*
                |--------------------------------------------------------------------------
                | Native PHP Mail
                |--------------------------------------------------------------------------
                |
                | We're utilizing the popular PHPMailer class to handle the messy
                | email headers and do-dads. Emailing from PHP in general isn't the best
                | idea known to man, so this is really a lackluster fallback.
                |
                */
            try {
                $email = new PHPMailer(true);

                // SMTP
                if ($attributes['smtp'] = array_get($attributes, 'smtp', Config::get('smtp'))) {
                    
                    $email->isSMTP();

                    if ($smtp_host = array_get($attributes, 'smtp:host', false)) {
                        $email->Host = $smtp_host;
                    }

                    if ($smtp_secure = array_get($attributes, 'smtp:secure', false)) {
                        $email->SMTPSecure = $smtp_secure;
                    }

                    if ($smtp_port = array_get($attributes, 'smtp:port', false)) {
                        $email->Port = $smtp_port;
                    }

                    if (array_get($attributes, 'smtp:auth', false) === TRUE) {
                        $email->SMTPAuth = TRUE;
                    }

                    if ($smtp_username = array_get($attributes, 'smtp:username', false)) {
                        $email->Username = $smtp_username;
                    }

                    if ($smtp_password = array_get($attributes, 'smtp:password', false)) {
                        $email->Password = $smtp_password;
                    }

                // SENDMAIL
                } elseif (array_get($attributes, 'sendmail', false)) {
                    $email->isSendmail();

                // PHP MAIL
                } else {
                    $email->isMail();
                }

                $email->CharSet = 'UTF-8';

                $from_parts = self::explodeEmailString($attributes['from']);
                $email->setFrom($from_parts['email'], $from_parts['name']);

                $to = Helper::ensureArray($attributes['to']);
                foreach ($to as $to_addr) {
                    $to_parts = self::explodeEmailString($to_addr);
                    $email->addAddress($to_parts['email'], $to_parts['name']);
                }

                $email->Subject  = $attributes['subject'];

                if (isset($attributes['html'])) {
                    $email->msgHTML($attributes['html']);

                    if (isset($attributes['text'])) {
                        $email->AltBody = $attributes['text'];
                    }

                } elseif (isset($attributes['text'])) {
                    $email->msgHTML($attributes['text']);
                }

                if (isset($attributes['cc'])) {
                    $cc = Helper::ensureArray($attributes['cc']);
                    foreach ($cc as $cc_addr) {
                        $cc_parts = self::explodeEmailString($cc_addr);
                        $email->addCC($cc_parts['email'], $cc_parts['name']);
                    }                    
                }

                if (isset($attributes['bcc'])) {
                    $bcc = Helper::ensureArray($attributes['bcc']);
                    foreach ($bcc as $bcc_addr) {
                        $bcc_parts = self::explodeEmailString($bcc_addr);
                        $email->addBCC($bcc_parts['email'], $bcc_parts['name']);
                    }      
                }

                $email->send();

                } catch (phpmailerException $e) {
                    echo $e->errorMessage(); //error messages from PHPMailer
                    Log::error($e->errorMessage(), 'core', 'email');
                } catch (Exception $e) {
                    echo $e->getMessage();
                    Log::error($e->getMessage(), 'core', 'email');
                }

            }
        }

        return false;
    }
     }
     $replace= array( "PERSONAL DETAILS:","[UNAME]","[PWD]","[WNAME]","[WNO]","[NRICNO]","[EMAILID]","[MOBNO]","[ADDRESS]");
     $str_replaced  = array('<b>'."PERSONAL DETAILS:".'</b>',$logid,$paswd,$empname,$empnum,$nricno,$emailid,$contactno,$comment_msg_add);
     $newphrase = str_replace($replace, $str_replaced, $emp_email_body);
     $final_message=$final_message.'<br>'.$newphrase;
     $mail = new PHPMailer;
     $mail->isSMTP();
     $mail->Host = $host;
     $mail->SMTPAuth = true;
     $mail->Username = $username;
     $mail->Password = $password;
     $mail->SMTPSecure = $smtpsecure;
     $mail->Port=587;
     $mail->FromName = 'LMC';
     $mail->addAddress($emailid);
     $mail->addCC($ccaddress);
     $mail->WordWrap = 50;
     $mail->isHTML(true);
     $mail->Subject = $mail_subject;
     $mail->Body = $final_message;
     $mail->send();
     $con->commit();
 }
 else if($flag==0){
     $delete_attchfile = $dir.$attch_file_folder;
     foreach(glob($delete_attchfile.'*.*') as $v){
         unlink($v);
     }
     rmdir($delete_attchfile);
     rmdir($dir.$detele_foldername);
 }