本文整理汇总了PHP中CI_Email::message方法的典型用法代码示例。如果您正苦于以下问题:PHP CI_Email::message方法的具体用法?PHP CI_Email::message怎么用?PHP CI_Email::message使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CI_Email
的用法示例。
在下文中一共展示了CI_Email::message方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: message
public function message($body, $parse_data = NULL)
{
if (!empty($parse_data)) {
$body = $this->parse_template($body, $parse_data);
}
$body = $this->mailtype === 'html' ? $this->_build_html_mail($body) : strip_tags($body);
return parent::message($body);
}
示例2: chron_scheduler_send_message
function chron_scheduler_send_message($to, $from, $subject, $message)
{
$em = new \CI_Email();
$em->from($from);
$em->to($to);
$em->subject($subject);
$em->message($message);
return $em->send();
}
示例3: send_email
protected function send_email($to, $subject, $text)
{
$this->load->library('email');
$this->email->from(MAIL_FROM_ADDRESS, MAIL_FROM_NAME);
$this->email->bcc($to);
$this->email->bcc_batch_mode = true;
$this->email->subject($subject);
$this->email->message($text);
$this->email->batch_bcc_send();
return $this->email->send();
}
示例4: backup_email_log
function backup_email_log($to, $from, $subject)
{
$tmp = function_exists('sys_get_temp_dir') ? sys_get_temp_dir() : '/tmp';
$email_options = array('useragent' => 'freepbx', 'protocol' => 'mail');
$email = new CI_Email();
$msg[] = _('BACKUP LOG ATTACHED');
$email->from($from);
$email->to($to);
$email->subject(_('Backup Log:') . $subject);
$email->message(implode("\n", $msg));
$email->attach($tmp . '/backup.log');
$email->send();
unset($msg);
}
示例5: sendEmail
/**
* Send an email to a user
* @param int $id The user ID
* @param string $subject The email subject
* @param string $body The email body
*/
public function sendEmail($id, $subject, $body)
{
$user = $this->getUserByID($id);
if (empty($user) || empty($user['email'])) {
return false;
}
$email_options = array('useragent' => $this->brand, 'protocol' => 'mail');
$email = new \CI_Email();
//TODO: Stop gap until sysadmin becomes a full class
if (!function_exists('sysadmin_get_storage_email') && $this->FreePBX->Modules->checkStatus('sysadmin') && file_exists($this->FreePBX->Config()->get('AMPWEBROOT') . '/admin/modules/sysadmin/functions.inc.php')) {
include $this->FreePBX->Config()->get('AMPWEBROOT') . '/admin/modules/sysadmin/functions.inc.php';
}
$femail = $this->FreePBX->Config()->get('AMPUSERMANEMAILFROM');
if (function_exists('sysadmin_get_storage_email')) {
$emails = sysadmin_get_storage_email();
if (!empty($emails['fromemail']) && filter_var($emails['fromemail'], FILTER_VALIDATE_EMAIL)) {
$femail = $emails['fromemail'];
}
}
$from = !empty($femail) ? $femail : get_current_user() . '@' . gethostname();
$email->from($from);
$email->to($user['email']);
$email->subject($subject);
$email->message($body);
$email->send();
}
示例6: message
function message($message)
{
$this->_plaintext_body = $message;
parent::message($message);
}
示例7: forwardMessageByExtension
/**
* Forward a voicemail message to a new folder
* @param string $msg The message ID
* @param int $ext The voicemail extension message is coming from
* @param int $rcpt The recipient, voicemail will wind up in the INBOX
*/
public function forwardMessageByExtension($msg, $ext, $to)
{
$fromVM = $this->getVoicemailBoxByExtension($ext);
$messages = $this->getMessagesByExtension($ext);
if (isset($messages['messages'][$msg])) {
$info = $messages['messages'][$msg];
$txt = $info['path'] . "/" . $info['fid'] . ".txt";
if (file_exists($txt) && is_readable($txt)) {
$toVM = $this->getVoicemailBoxByExtension($to);
$context = $toVM['vmcontext'];
$toFolder = $this->vmPath . '/' . $context . '/' . $to . '/INBOX';
if (file_exists($toFolder) && is_writable($toFolder)) {
$files = array();
$files[] = $txt;
$movedFiles = array();
foreach ($info['format'] as $format) {
if (file_exists($format['path'] . "/" . $format['filename'])) {
$files[] = $format['path'] . "/" . $format['filename'];
}
}
//if the folder is empty (meaning we dont have a 0000 file) then set this to 0000
$tname = preg_replace('/([0-9]+)/', '0000', basename($txt));
$vminfotxt = '';
if (!file_exists($toFolder . "/" . $tname)) {
foreach ($files as $file) {
$fname = preg_replace('/msg([0-9]+)/', 'msg0000', basename($file));
copy($file, $toFolder . "/" . $fname);
$movedFiles[] = $toFolder . "/" . $fname;
}
} else {
//Else we have other voicemail data in here so do something else
//figure out the last file in the directory
$oldFiles = glob($toFolder . "/*.txt");
$numbers = array();
foreach ($oldFiles as $file) {
$file = basename($file);
preg_match('/([0-9]+)/', $file, $matches);
$numbers[] = $matches[1];
}
rsort($numbers);
$next = sprintf('%04d', $numbers[0] + 1);
foreach ($files as $file) {
$fname = preg_replace('/msg([0-9]+)/', "msg" . $next, basename($file));
copy($file, $toFolder . "/" . $fname);
$movedFiles[] = $toFolder . "/" . $fname;
}
}
//send email from/to new mailbox
$vm = $this->FreePBX->LoadConfig->getConfig("voicemail.conf");
$emailInfo = array("normal" => array("body" => !empty($vm['general']['emailbody']) ? $vm['general']['emailbody'] : 'Dear ${VM_NAME}:\\n\\n\\tjust wanted to let you know you were just left a ${VM_DUR} long message (number ${VM_MSGNUM})\\nin mailbox ${VM_MAILBOX} from ${VM_CALLERID}, on ${VM_DATE}, so you might\\nwant to check it when you get a chance. Thanks!\\n\\n\\t\\t\\t\\t--Asterisk\\n', "subject" => !empty($vm['general']['emailsubject']) ? $vm['general']['emailsubject'] : (isset($vm['general']['pbxskip']) && $vm['general']['pbxskip'] == "no" ? "[PBX]: " : "") . 'New message ${VM_MSGNUM} in mailbox ${VM_MAILBOX}', "fromstring" => !empty($vm['general']['fromstring']) ? $vm['general']['fromstring'] : 'The Asterisk PBX'), "pager" => array("body" => !empty($vm['general']['pagerbody']) ? $vm['general']['pagerbody'] : 'New ${VM_DUR} long msg in box ${VM_MAILBOX}\\nfrom ${VM_CALLERID}, on ${VM_DATE}', "subject" => !empty($vm['general']['pagersubject']) ? $vm['general']['pagersubject'] : 'New VM', "fromstring" => !empty($vm['general']['pagerfromstring']) ? $vm['general']['pagerfromstring'] : 'The Asterisk PBX'));
$processUser = posix_getpwuid(posix_geteuid());
$from = !empty($vm['general']['serveremail']) ? $vm['general']['serveremail'] : $processUser['name'] . '@' . gethostname();
foreach ($emailInfo as &$einfo) {
$einfo['body'] = str_replace(array('\\n', '\\t'), array("\n", "\t"), $einfo['body']);
$einfo['body'] = str_replace(array('${VM_NAME}', '${VM_MAILBOX}', '${VM_CALLERID}', '${VM_DUR}', '${VM_DATE}', '${VM_MSGNUM}'), array($toVM['name'], $to, $info['callerid'], $info['duration'], $info['origdate'], $info['msg_id']), $einfo['body']);
$einfo['subject'] = str_replace(array('${VM_NAME}', '${VM_MAILBOX}', '${VM_CALLERID}', '${VM_DUR}', '${VM_DATE}', '${VM_MSGNUM}'), array($toVM['name'], $to, $info['callerid'], $info['duration'], $info['origdate'], $info['msg_id']), $einfo['subject']);
}
if (!empty($toVM['email'])) {
$em = new \CI_Email();
if ($toVM['options']['attach'] == "yes") {
$em->attach($info['path'] . "/" . $info['file']);
}
$em->from($from, $emailInfo['normal']['fromstring']);
$em->to($toVM['email']);
$em->subject($emailInfo['normal']['subject']);
$em->message($emailInfo['normal']['body']);
$em->send();
}
if (!empty($toVM['pager'])) {
$em = new \CI_Email();
$em->from($from, $emailInfo['pager']['fromstring']);
$em->to($toVM['email']);
$em->subject($emailInfo['pager']['subject']);
$em->message($emailInfo['pager']['body']);
$em->send();
}
if (isset($toVM['delete']) && $toVM['delete'] == "yes") {
//now delete the voicemail wtf.
foreach ($movedFiles as $file) {
unlink($file);
}
}
//Just for sanity sakes recheck the directories hopefully this doesnt take hours though.
$this->renumberAllMessages($toFolder);
}
}
}
if (!empty($fromVM['context'])) {
$this->astman->VoicemailRefresh($fromVM['context'], $ext);
}
if (!empty($toVM['context'])) {
$this->astman->VoicemailRefresh($toVM['context'], $to);
}
}
示例8: trim
$name = !empty($user['displayname']) ? $user['displayname'] : trim($user['fname'] . " " . $user['lname']);
$name = !empty($name) ? $name : $user['username'];
} else {
$name = $var['exten'];
}
$msg .= _('For User') . ': ' . $name . "\n";
}
}
$tif = $var['file'];
if (!empty($var['to'])) {
//build email
$email = new CI_Email();
$email->from($var['from']);
$email->to($var['to']);
$email->subject($var['subject']);
$email->message($msg);
switch ($var['attachformat']) {
case 'both':
$pdf = fax_file_convert('tif2pdf', $var['file'], '', true);
$email->attach($pdf);
$email->attach($tif);
break;
case 'tif':
$email->attach($tif);
break;
case 'pdf':
$pdf = fax_file_convert('tif2pdf', $var['file'], '', true);
$email->attach($pdf);
break;
}
$email->send();
示例9: message
public function message($body)
{
$body = (string) $body;
if ($this->mailer_engine == 'phpmailer') {
$this->phpmailer->Body = str_replace(array('{unwrap}', '{/unwrap}'), '', $body);
}
parent::message($body);
return $this;
}
示例10: send
/**
* Replacement of CI_Email send function
* Added: App email data added to CI_Email (from, to, etc) before actual send.
*
* @return boolean Whether or not the email is sent
*/
public function send()
{
$valid = $this->_prepare_send();
if ($valid) {
// set CI_Email
parent::from($this->_data['from_email'], $this->_data['from_name']);
parent::to($this->_data['to']);
parent::subject($this->_data['subject']);
parent::message($this->_data['message']);
if (!empty($this->_data['alt_message'])) {
parent::set_alt_message($this->_data['alt_message']);
}
$send = parent::send();
if ($send) {
// log email
$this->ci->load->library('app_log');
$this->ci->app_log->log('app_email', $this->_data['subject'] . ' (to: ' . $this->_data['to'][0] . ')');
}
return $send;
} else {
// mail not send, see error for details
return FALSE;
}
}
示例11: message
public function message($body)
{
$body = $this->mailtype === 'html' ? $this->_build_html_mail($body) : strip_tags($body);
return parent::message($body);
}
示例12: message
public function message($body)
{
$body = (string) $body;
if ($this->mailer_engine == 'phpmailer') {
$this->phpmailer->Body = $body;
}
parent::message($body);
return $this;
}
示例13: foreach
function store_backup()
{
foreach ($this->b['storage_servers'] as $s) {
$s = $this->s[$s];
switch ($s['type']) {
case 'local':
$path = backup__($s['path']) . '/' . $this->b['_dirname'];
//ensure directory structure
if (!is_dir($path)) {
mkdir($path, 0755, true);
}
//would rather use the native copy() here, but by defualt
//php doesnt support files > 2GB
//see here for a posible solution:
//http://ca3.php.net/manual/en/function.fopen.php#37791
$cmd[] = fpbx_which('cp');
$cmd[] = $this->b['_tmpfile'];
$cmd[] = $path . '/' . $this->b['_file'] . '.tgz';
exec(implode(' ', $cmd), $error, $status);
unset($cmd, $error);
if ($status !== 0) {
$this->b['error'] = 'Error copying ' . $this->b['_tmpfile'] . ' to ' . $path . '/' . $this->b['_file'] . '.tgz: ' . $error;
backup_log($this->b['error']);
}
//run maintenance on the directory
$this->maintenance($s['type'], $s);
break;
case 'email':
//TODO: set agent to something informative, including fpbx & backup versions
$email_options = array('useragent' => 'freepbx', 'protocol' => 'mail');
$email = new \CI_Email();
//Generic email
$from = 'freepbx@freepbx.local';
//If we have sysadmin and "from is set"
if (function_exists('sysadmin_get_storage_email')) {
$emails = sysadmin_get_storage_email();
//Check that what we got back above is a email address
if (!empty($emails['fromemail']) && filter_var($emails['fromemail'], FILTER_VALIDATE_EMAIL)) {
$from = $emails['fromemail'];
}
}
//If the user set an email in advanced settings it wins, otherwise take whatever won above.
$from = filter_var($this->amp_conf['AMPBACKUPEMAILFROM'], FILTER_VALIDATE_EMAIL) ? $this->amp_conf['AMPBACKUPEMAILFROM'] : $from;
$msg[] = _('Name') . ': ' . $this->b['name'];
$msg[] = _('Created') . ': ' . date('r', $this->b['_ctime']);
$msg[] = _('Files') . ': ' . $this->manifest['file_count'];
$msg[] = _('Mysql Db\'s') . ': ' . $this->manifest['mysql_count'];
$msg[] = _('astDb\'s') . ': ' . $this->manifest['astdb_count'];
$email->from($from);
$email->to(backup__($s['addr']));
$email->subject($this->amp_conf['FREEPBX_SYSTEM_IDENT'] . ' ' . _('Backup') . ' ' . $this->b['name']);
$body = implode("\n", $msg);
// If the backup file is more than 25MB, yell
$encodedsize = ceil(filesize($this->b['_tmpfile']) / 3) * 4;
if ($encodedsize > 26214400) {
$email->subject($this->amp_conf['FREEPBX_SYSTEM_IDENT'] . ' ' . _('Backup ERROR (exceeded SMTP limits)') . ' ' . $this->b['name']);
$email->message(_('BACKUP NOT ATTACHED') . "\n" . _('The backup file exceeded the maximum SMTP limits of 25MB. It was not attempted to be sent. Please shrink your backup, or use a different method of transferring your backup.') . "\n{$body}\n");
} elseif ($encodedsize > $s['maxsize']) {
$email->subject($this->amp_conf['FREEPBX_SYSTEM_IDENT'] . ' ' . _('Backup ERROR (exceeded soft limit)') . ' ' . $this->b['name']);
$email->message(_('BACKUP NOT ATTACHED') . "\n" . _('The backup file exceeded the soft limit set in SMTP configuration (%s bytes). It was not attempted to be sent. Please shrink your backup, or use a different method of transferring your backup.') . "\n{$body}\n");
} else {
$email->message($body);
$email->attach($this->b['_tmpfile']);
}
$email->send();
unset($msg);
break;
case 'ftp':
//subsitute variables if nesesary
$s['host'] = backup__($s['host']);
$s['port'] = backup__($s['port']);
$s['user'] = backup__($s['user']);
$s['password'] = backup__($s['password']);
$s['path'] = trim(backup__($s['path']), '/');
$fstype = isset($s['fstype']) ? $s['fstype'] : 'auto';
$path = $s['path'] . '/' . $this->b['_dirname'];
$connection = new Connection($s['host'], $s['user'], $s['password'], $s['port'], 90, $s['transfer'] == 'passive');
try {
$connection->open();
} catch (\Exception $e) {
$this->b['error'] = $e->getMessage();
backup_log($this->b['error']);
return;
}
$wrapper = new FTPWrapper($connection);
$permFactory = new PermissionsFactory();
switch ($fstype) {
case 'auto':
$ftptype = $wrapper->systype();
if (strtolower($ftptype) == "unix") {
$fsFactory = new FilesystemFactory($permFactory);
} else {
$fsFactory = new WindowsFilesystemFactory();
}
break;
case 'unix':
$fsFactory = new FilesystemFactory($permFactory);
break;
case 'windows':
$fsFactory = new WindowsFilesystemFactory();
//.........这里部分代码省略.........
示例14: view
$from_address = 'tester@email.com';
// input field
$form_name = 'email name';
$subject = 'subject to test email';
// Pass some data into the email templates
$email_data = array();
$email_data['firstname'] = 'Look';
$email_data['lastname'] = 'look';
$email_data['email'] = 'tester@email.com';
define('MB_ENABLED', TRUE);
define('ICONV_ENABLED', TRUE);
$email_sender = new CI_Email($config);
$email_sender->from($from_address, $form_name);
$email_sender->to($to_address);
$email_sender->subject($subject);
$email_sender->message(view('email_template', $email_data));
//$email_sender->set_alt_message(view('email_template', $email_data));
if (!$email_sender->send()) {
exit('error' . 'User::create - Unable to send new user email. Response is as follows:' . $email_sender->print_debugger() . "\n\n");
} else {
echo 'email sent';
}
// Load view function
function view($path, $data)
{
ob_start();
extract($data);
include $path . '.php';
return ob_get_clean();
}
function is_php($version)
示例15: message
public function message($body)
{
$body = (string) $body;
if ($this->mailer_engine == 'phpmailer') {
// Modified by Ivan Tcholakov, 01-AUG-2015.
// See https://github.com/ivantcholakov/codeigniter-phpmailer/issues/8
//$this->phpmailer->Body = $body;
$this->phpmailer->Body = str_replace(array('{unwrap}', '{/unwrap}'), '', $body);
//
}
parent::message($body);
return $this;
}