/** * Send the mail. * * @param Midas_Mail $mail mail instance * @throws Midas_Service_AppEngine_Exception */ public function sendMail(Midas_Mail $mail) { if (is_null($this->_client)) { $this->_client = new \google\appengine\api\mail\Message(); } $this->_client->addBcc($mail->getBcc()); $this->_client->addCc($mail->getCc()); $this->_client->addTo($mail->getTo()); $this->_client->setHtmlBody($mail->getBodyHtml(true)); $this->_client->setReplyTo($mail->getReplyTo()); $this->_client->setSender($mail->getFrom()); $this->_client->setSubject($mail->getSubject()); $this->_client->setTextBody($mail->getBodyText(true)); try { $this->_client->send(); } catch (\Exception $exception) { throw new Midas_Service_AppEngine_Exception($exception); } }
$result = $select->fetch_assoc(); $temp_table_name = $result['@TEMP_CLOCK_OUT_MISSED_DETAILS']; $select_data = "select * from {$temp_table_name} ORDER BY EMPLOYEE_NAME "; $select_data_rs = mysqli_query($con, $select_data); $row = mysqli_num_rows($select_data_rs); $x = $row; if ($x > 0) { while ($row = mysqli_fetch_array($select_data_rs)) { $adm_employeename = $row["EMPLOYEE_NAME"]; $adm_date = $row["REPORT_DATE"]; $message = $message . "<tr><td width=220>" . $adm_employeename . "</td><td width=150>" . $adm_date . "</td></tr>"; } $message = $message . "</table></body></html>"; $REP_subject_date = $mail_subject; //SENDING MAIL OPTIONS $name = $mail_subject; $from = $admin; $message1 = new Message(); $message1->setSender($name . '<' . $from . '>'); $message1->addTo($admin); $message1->addCc($sadmin); $message1->setSubject($REP_subject_date); $message1->setHtmlBody($message); try { $message1->send(); } catch (\InvalidArgumentException $e) { echo $e; } } $drop_query = "DROP TABLE {$temp_table_name} "; mysqli_query($con, $drop_query);
public function getBanktt_UpdateSave($UserStamp) { $id=$_POST['Temp_Bt_id']; $type=$_POST['Banktt_SRC_TTtype']; $date=date('Y-m-d',strtotime($_POST['Banktt_SRC_Date'])); $model=$_POST['Banktt_SRC_Modelnames'];if($model=='SELECT'){$model='';} $accname=$_POST['Banktt_SRC_Accname']; $accno=$_POST['Banktt_SRC_Accno']; $amount=$_POST['Banktt_SRC_Amount']; $unit=$_POST['Banktt_SRC_Unit'];if($unit=="SELECT"){$unit="";} $customername=$_POST['Banktt_SRC_Customername'];if($customername=="SELECT"){$customername="";} $customerid=$_POST['temp_customerid']; $bankttcode=$_POST['Banktt_SRC_Bankcode']; $banktt_branchcode=$_POST['Banktt_SRC_Branchcode']; $bankaddress=$this->db->escape_like_str($_POST['Banktt_SRC_BankAddress']); $swiftcode=$_POST['Banktt_SRC_Swiftcode']; $chargesto=$_POST['Banktt_SRC_Chargesto'];if($chargesto=="SELECT"){$chargesto='';} $customerref=$this->db->escape_like_str($_POST['Banktt_SRC_Customerref']); $invdetails=$this->db->escape_like_str($_POST['Banktt_SRC_Invdetails']); $createdby=$_POST['Banktt_SRC_Createdby'];if($createdby=='SELECT'){$createdby='';} $comments=$this->db->escape_like_str($_POST['Banktt_SRC_Comments']); $status=$_POST['Banktt_SRC_Status']; if($_POST['Banktt_SRC_Debitedon']!='') { $debitedon=date('Y-m-d',strtotime($_POST['Banktt_SRC_Debitedon'])); } else { $debitedon=''; } if($chargesto!='' && $createdby!=''){$configdatas=$status.','.$createdby.','.$chargesto;} else if($chargesto!=''){$configdatas=$status.','.$chargesto;} else if($createdby!=''){$configdatas=$status.','.$createdby;} else{$configdatas=$status;} $this->db->query('SET AUTOCOMMIT=0'); $this->db->query('START TRANSACTION'); $BANKTT_SRC_updatequery="CALL SP_BANK_TT_UPDATE($id,'$configdatas','$model','$date',$amount,'$accname','$accno','$bankttcode','$banktt_branchcode','$bankaddress','$swiftcode','$customerref','$invdetails','$debitedon','$comments','$UserStamp',@BANK_SUCCESSFLAG,@BANK_SAVEPOINT)"; $this->db->query($BANKTT_SRC_updatequery); $outparm_query = 'SELECT @BANK_SUCCESSFLAG AS MESSAGE'; $outparm_result = $this->db->query($outparm_query); $Confirm_mrssage=$outparm_result->row()->MESSAGE; $outparm_query_savepoint = 'SELECT @BANK_SAVEPOINT AS SAVEPOINT'; $outparm_result_savepoint = $this->db->query($outparm_query_savepoint); $banktt_savepoint_update=$outparm_result_savepoint->row()->SAVEPOINT; $this->load->model('EILIB/Mdl_eilib_common_function'); $Sendmailid=$this->Mdl_eilib_common_function->getProfileEmailId('BANKTT'); $Displayname=$this->Mdl_eilib_common_function->Get_MailDisplayName('BANK_TT'); $username=explode('@',$Sendmailid[0]); $mailusername=strtoupper($username[0]); $headerarray=['DATE','TRANSACTION TYPE','MODEL NAME','ACC NAME','ACC NO','AMOUNT','UNIT','CUSTOMER','STATUS','DEBITED/REJECTED DATE','BANK CODE','BRANCH CODE','BANK ADDRESS','SWIFT CODE','CHARGES TO','CUST REF','INV DETAILS','DONE BY','COMMENTS']; $dataarray=[$_POST['Banktt_SRC_Date'],$type,$model,$accname,$accno,$amount,$unit,$customername,$status,$debitedon,$bankttcode,$banktt_branchcode,$_POST['Banktt_SRC_BankAddress'],$swiftcode,$chargesto,$_POST['Banktt_SRC_Customerref'],$_POST['Banktt_SRC_Invdetails'],$createdby,$_POST['Banktt_SRC_Comments']]; $subject="HELLO".','."<font color='gray'></font><font color='#498af3'><b>".$mailusername."</b> </font><br>PLEASE FIND ATTACHED NEW TRANSACTION DETAILS FROM BANK TT: <br>"; $message = '<body><br><h> '.$subject.'</h><br></body>'; for($i=0;$i<count($dataarray);$i++) { $value=$dataarray[$i]; if($customername!=null){$customername=str_replace('_',' ',$customername);} if($value=="" || $value=="SELECT" || $value==null)continue; if($value!='REJECTED') { $message.= '<body><table border="1"width="600" ><tr align="left" ><td width=40%>'.$headerarray[$i].'</td><td width=60%>'.$value.'</td></tr></table></body>'; } else { $message.= '<body><table border="1"width="600" ><tr align="left" ><td width=40%>'.$headerarray[$i].'</td><td width=60%><span style="background-color:#FF0000">'.$value.'</span></td></tr></table></body>'; } } if($status!='REJECTED') { $emailsubject="BANK TRANSFER"; } else { $emailsubject="BANK TRANSFER-REJECTED"; } $returnvalues=array($Confirm_mrssage,$emailsubject,$message,$Displayname,$Sendmailid); if($returnvalues[0]==1) { try{ $message1 = new Message(); $message1->setSender($returnvalues[3].'<'.$UserStamp.'>'); $message1->addTo($returnvalues[4][0]); $message1->addCc($returnvalues[4][1]); $message1->setSubject($returnvalues[1]); $message1->setHtmlBody($returnvalues[2]); $message1->send(); $this->db->trans_savepoint_release($banktt_savepoint_update) ;} catch(Exception $e){ $this->db->trans_savepoint_rollback($banktt_savepoint_update); return array("RECORD NOT UPDATED",$emailsubject,$message,$Displayname,$Sendmailid); } }else{ $this->db->trans_savepoint_rollback($banktt_savepoint_update); return array("RECORD NOT UPDATED",$emailsubject,$message,$Displayname,$Sendmailid); } return $returnvalues; }
public function ERM_Update_Record($displayname,$Emailtemplate,$Rowid,$Name,$Rent,$Movedate,$Minstay,$Occupation,$Nation,$Guests,$Custage,$Contactno,$Emailid,$Comment,$UserStamp,$timeZoneFormat,$username) { $Min_stay=$this->db->escape_like_str($Minstay); $Guest=$this->db->escape_like_str($Guests); $age=$this->db->escape_like_str($Custage); $Comments=$this->db->escape_like_str($Comment); $Movedate=date('Y-m-d',strtotime($Movedate)); $this->db->query('SET AUTOCOMMIT=0'); $this->db->query('START TRANSACTION'); $CallQuery="CALL SP_ERM_UPDATE('$Occupation',$Rowid,'$Name','$Rent','$Movedate','$Min_stay','$Nation','$Guest','$age','$Contactno','$Emailid','$Comments','$UserStamp',@ERM_SUCCESSFLAG,@ERM_UPDATE_SAVE_POINT)"; $this->db->query($CallQuery); $ERM_Entry_flag = 'SELECT @ERM_SUCCESSFLAG as FLAG_INSERT'; $query = $this->db->query($ERM_Entry_flag); $Confirm_Meessage=$query->row()->FLAG_INSERT; $query_updateSavepoint= $this->db->query('SELECT @ERM_UPDATE_SAVE_POINT as ERM_UPDATE_SAVEPOINT'); $erm_update_savepoint=$query_updateSavepoint->row()->ERM_UPDATE_SAVEPOINT; $Timestamp; if($Confirm_Meessage==1) { $SelectQuery="SELECT DATE_FORMAT(CONVERT_TZ(ERM_TIMESTAMP,$timeZoneFormat),'%d-%m-%Y %T') AS ERM_TIME_STAMP FROM ERM_ENTRY_DETAILS WHERE ERM_ID=".$Rowid; $query = $this->db->query($SelectQuery); $Timestamp=$query->row()->ERM_TIME_STAMP; } $Movedate=date('d-m-Y',strtotime($Movedate)); $dataarray=array($Name,$Rent,$Movedate,$Minstay,$Occupation,$Nation,$Guests,$Custage,$Contactno,$Emailid,$Comment); $head_array=array('CUSTOMER NAME','RENT','MOVING DATE','MIN STAY','OCCUPATION','NATIONALITY','NO OF GUESTS','AGE','CONTACT','EMAIL','COMMENTS'); $subject="HELLO "."<font color='gray'></font><font color='#498af3'><b>$username</b> </font><br>PLEASE FIND ATTACHED NEW LEED DETAILS FROM ERM: <br>"; $message = '<body><br><h> '.$subject.'</h><br</body>'; if($Confirm_Meessage==1) { for($i=0;$i<count($head_array);$i++) { $value=$dataarray[$i]; if($value=="" || $value==null)continue; $message .= '<body><table border="1"width="500" ><tr align="left" ><td width=40%>'.$head_array[$i].'</td><td width=60%>'.$value.'</td></tr></table></body>'; } } $Return_values=array($Confirm_Meessage,$Timestamp,$UserStamp,$message); $message=$Return_values[3]; $mydate=getdate(date("U")); $month=strtoupper($mydate[month]); $sysdate="$mydate[mday]-$month-$mydate[year]"; $emailsubject="NEW ERM LEED -[".$sysdate."]"; if($Return_values[0]==1) { try{ $message1 = new Message(); $message1->setSender($displayname.'<'.$UserStamp.'>'); $message1->addTo($Emailtemplate[0]); $message1->addCc($Emailtemplate[1]); $message1->setSubject($emailsubject); $message1->setHtmlBody($message); $message1->send(); $this->db->trans_savepoint_release($erm_update_savepoint) ; } catch(Exception $e){ $this->db->trans_savepoint_rollback($erm_update_savepoint); return array("RECORD NOT UPDATED",$Timestamp,$UserStamp,$message); } }else{ $this->db->trans_savepoint_rollback($erm_update_savepoint); return array("RECORD NOT UPDATED",$Timestamp,$UserStamp,$message); } return $Return_values; }
/** * Send email * * This is based on {@see wp_mail()} which is in turn based on PHP's * built-in mail() function. This is typically called from the overriden * version of {@see wp_mail()} below. * * @param string|array $to Array or comma-separated list of email addresses to send message. * @param string $subject Email subject * @param string $message Message contents * @param string|array $headers Optional. Additional headers. * @param string|array $attachments Optional. Files to attach. * * @return bool Whether the email contents were sent successfully. */ function send_mail($to, $subject, $message, $headers = '', $attachments = array()) { // Compact the input, apply the filters, and extract them back out extract(apply_filters('wp_mail', compact('to', 'subject', 'message', 'headers', 'attachments'))); global $phpmailer; if (!is_object($phpmailer) || !is_a($phpmailer, 'Message')) { $phpmailer = new Message(); } $cc = array(); $bcc = array(); // Headers if (empty($headers)) { $headers = array(); } else { if (!is_array($headers)) { // Explode the headers out, so this function can take both // string headers and an array of headers. $tempheaders = explode("\n", str_replace("\r\n", "\n", $headers)); } else { $tempheaders = $headers; } $headers = array(); // If it's actually got contents if (!empty($tempheaders)) { // Iterate through the raw headers foreach ((array) $tempheaders as $header) { if (false === strpos($header, ':')) { if (false !== stripos($header, 'boundary=')) { $parts = preg_split('/boundary=/i', trim($header)); $boundary = trim(str_replace(array("'", '"'), '', $parts[1])); } continue; } // Explode them out list($name, $content) = explode(':', trim($header), 2); // Cleanup crew $name = trim($name); $content = trim($content); switch (strtolower($name)) { // Mainly for legacy -- process a From: header if it's there case 'from': if (false !== strpos($content, '<')) { // So... making my life hard again? $from_name = substr($content, 0, strpos($content, '<') - 1); $from_name = str_replace('"', '', $from_name); $from_name = trim($from_name); $from_email = substr($content, strpos($content, '<') + 1); $from_email = str_replace('>', '', $from_email); $from_email = trim($from_email); } else { $from_email = trim($content); } break; case 'content-type': if (false !== strpos($content, ';')) { list($type, $charset) = explode(';', $content); $content_type = trim($type); if (false !== stripos($charset, 'charset=')) { $charset = trim(str_replace(array('charset=', '"'), '', $charset)); } elseif (false !== stripos($charset, 'boundary=')) { $boundary = trim(str_replace(array('BOUNDARY=', 'boundary=', '"'), '', $charset)); $charset = ''; } } else { $content_type = trim($content); } break; case 'cc': $cc = array_merge((array) $cc, explode(',', $content)); break; case 'bcc': $bcc = array_merge((array) $bcc, explode(',', $content)); break; default: // Add it to our grand headers array $headers[trim($name)] = trim($content); break; } } } } // Empty out the values that may be set $phpmailer->clearBcc(); $phpmailer->clearCc(); $phpmailer->clearReplyTo(); $phpmailer->clearTo(); // From email and name // If we don't have a name from the input headers if (!isset($from_name)) { $from_name = 'App Engine'; } /* If we don't have an email from the input headers default to wordpress@$sitename * Some hosts will block outgoing mail from this address if it doesn't exist but * there's no easy alternative. Defaulting to admin_email might appear to be another * option but some hosts may refuse to relay mail from an unknown domain. See * http://trac.wordpress.org/ticket/5007. */ if (!isset($from_email)) { $from_email = get_option('appengine_email', false); if (!$from_email) { $from_email = get_default_email(); } } // Plugin authors can override the potentially troublesome default // TODO: Currently, App Engine doesn't support a from name. We should // come back to this and fix it if/when it does //$phpmailer->setSender( apply_filters( 'wp_mail_from_name', $from_name ) . " <" . apply_filters( 'wp_mail_from', $from_email ) . ">"); $phpmailer->setSender(apply_filters('wp_mail_from', $from_email)); // Set destination addresses if (!is_array($to)) { $to = explode(',', $to); } foreach ((array) $to as $recipient) { try { // Break $recipient into name and address parts if in the format "Foo <*****@*****.**>" $recipient_name = ''; if (preg_match('/(.*)<(.+)>/', $recipient, $matches)) { if (count($matches) == 3) { $recipient_name = $matches[1]; $recipient = $matches[2]; } } $phpmailer->addTo($recipient, $recipient_name); } catch (Exception $e) { syslog(LOG_DEBUG, 'Mail error: ' . $e->getMessage()); continue; } } // Add any CC and BCC recipients $cc = array_filter($cc); $bcc = array_filter($bcc); if (!empty($cc)) { foreach ((array) $cc as $recipient) { try { // Break $recipient into name and address parts if in the format "Foo <*****@*****.**>" $recipient_name = ''; if (preg_match('/(.*)<(.+)>/', $recipient, $matches)) { if (count($matches) == 3) { $recipient_name = $matches[1]; $recipient = $matches[2]; } } $phpmailer->addCc($recipient, $recipient_name); } catch (Exception $e) { syslog(LOG_DEBUG, 'Mail error: ' . $e->getMessage()); continue; } } } if (!empty($bcc)) { foreach ((array) $bcc as $recipient) { try { // Break $recipient into name and address parts if in the format "Foo <*****@*****.**>" $recipient_name = ''; if (preg_match('/(.*)<(.+)>/', $recipient, $matches)) { if (count($matches) == 3) { $recipient_name = $matches[1]; $recipient = $matches[2]; } } $phpmailer->addBcc($recipient, $recipient_name); } catch (Exception $e) { syslog(LOG_DEBUG, 'Mail error: ' . $e->getMessage()); continue; } } } // Set Content-Type and charset // If we don't have a content-type from the input headers if (!isset($content_type)) { $content_type = 'text/plain'; } $content_type = apply_filters('wp_mail_content_type', $content_type); // Set whether it's plaintext, depending on $content_type if ('text/html' == $content_type) { $phpmailer->setHtmlBody($message); } else { $phpmailer->setTextBody($message); } $phpmailer->setSubject($subject); // If we don't have a charset from the input headers if (!isset($charset)) { $charset = get_bloginfo('charset'); } // Set the content-type and charset //$phpmailer->charsset = apply_filters( 'wp_mail_charset', $charset ); // Set custom headers if (!empty($headers)) { if (isset($headers['MIME-Version'])) { unset($headers['MIME-Version']); } $phpmailer->addHeaderArray($headers); if (false !== stripos($content_type, 'multipart') && !empty($boundary)) { $phpmailer->addHeaderArray('Content-Type', sprintf("%s;\n\t boundary=\"%s\"", $content_type, $boundary)); } } if (!empty($attachments)) { foreach ($attachments as $attachment) { try { $name = basename($attachment); $data = file_get_contents($attachment); $phpmailer->addAttachment($name, $data); } catch (Exception $e) { syslog(LOG_DEBUG, 'Mail error: ' . $e->getMessage()); continue; } } } // Send! $phpmailer->send(); return true; }