本文整理汇总了PHP中self::send方法的典型用法代码示例。如果您正苦于以下问题:PHP self::send方法的具体用法?PHP self::send怎么用?PHP self::send使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类self
的用法示例。
在下文中一共展示了self::send方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: quickSend
/**
* Quick translated sending
*
* @param string $translation_id
* @param mixed $to recipient / guest / email
* @param mixed ... additionnal translation variables
*/
public static function quickSend($translation_id, $to)
{
// Get additionnal arguments
$vars = array_slice(func_get_args(), 2);
// Manage recipient if object given, get language if possible
$lang = null;
if (is_object($to)) {
array_unshift($vars, $to);
if ($to instanceof User) {
$lang = $to->lang;
$to = $to->email;
}
if ($to instanceof Recipient) {
$lang = $to->transfer->lang;
}
}
// Translate email and replace variables
$tr = Lang::translateEmail($translation_id, $lang);
if ($vars) {
$tr = call_user_func_array(array($tr, 'replace'), $vars);
}
// Create email and send it right away
$mail = new self($tr);
$mail->to($to);
$mail->send();
}
示例2: processCron
/**
* Processes update e-mails for all users
*/
public static function processCron($controller)
{
// Detect the mailing interval we're in
$interval = 0;
if (Yii::$app->controller->action->id == 'hourly') {
$interval = self::INTERVAL_HOURY;
} elseif (Yii::$app->controller->action->id == 'daily') {
$interval = self::INTERVAL_DAILY;
} else {
throw new \yii\console\Exception('Invalid mail update interval!');
}
// Get users
$users = User::find()->distinct()->joinWith(['httpSessions', 'profile'])->where(['user.status' => User::STATUS_ENABLED]);
$totalUsers = $users->count();
$processed = 0;
Console::startProgress($processed, $totalUsers, 'Sending update e-mails to users... ', false);
$mailsSent = 0;
foreach ($users->each() as $user) {
$mailSender = new self();
$mailSender->user = $user;
$mailSender->interval = $interval;
if ($mailSender->send()) {
$mailsSent++;
}
Console::updateProgress(++$processed, $totalUsers);
}
Console::endProgress(true);
$controller->stdout('done - ' . $mailsSent . ' email(s) sent.' . PHP_EOL, Console::FG_GREEN);
// Switch back to system language
self::switchLanguage();
}
示例3: quickSend
/**
* Quick translated sending
*
* @param string $translation_id
* @param mixed ... additionnal translation variables
*/
public static function quickSend($translation_id)
{
$vars = array_slice(func_get_args(), 1);
$tr = Lang::translateEmail($translation_id);
if ($vars) {
$tr = call_user_func_array(array($tr, 'replace'), $vars);
}
$mail = new self($tr);
$mail->send();
}
示例4: post
/**
* @param string $url
* @param array $post
* @param wfWAFHTTP $request
* @return wfWAFHTTPResponse|bool
* @throws wfWAFHTTPTransportException
*/
public static function post($url, $post = array(), $request = null)
{
if (!$request) {
$request = new self();
}
$request->setUrl($url);
$request->setMethod('POST');
$request->setBody($post);
$request->setTransport(wfWAFHTTPTransport::getInstance());
return $request->send();
}
示例5: validate
public static function validate(User $user)
{
$email = new self();
$email->headers = "From: " . self::$from . "\r\n";
$email->headers .= "MIME-Version: 1.0\r\n";
$email->headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$email->to = $user->email;
$email->subject = "AOD Division Tracker - Email verification";
$email->message .= "<h1><strong>{$user->username}</strong>,</h1>";
$email->message .= "<p>This email was used by someone with the IP {$_SERVER['REMOTE_ADDR']} to create an account on the AOD Division Tracker. Please verify that it was you by clicking the link provided below, or copy-paste the URL into your browser's address bar.</p>";
$email->message .= "<p>http://aodwebhost.site.nfoservers.com/tracker/authenticate?id={$user->validation}\r\n\r\n</p>";
$email->message .= "<p><small>If you believe you have received this email in error, or the account was not created by you, please let us know by sending an email to admin@aodwebhost.site.nfoservers.com</small></p>";
$email->message .= "<p><small>PLEASE DO NOT REPLY TO THIS E-MAIL</small></p>";
$email->send();
}
示例6: launch
/**
* Launch the whole job
*
* @param $scenario
*
* @throws \Exception
*/
public static function launch($scenario)
{
// add autoloader
static::register();
$scenario = __DIR__ . '/../scenario/' . $scenario;
// check the given scenario
if (is_readable($scenario)) {
$scenario = json_decode(file_get_contents($scenario), true);
if (!is_null($scenario) && static::isValid($scenario)) {
try {
$scenario = new self($scenario);
$scenario->send();
} catch (\Exception $e) {
throw $e;
}
exit;
}
throw new \Exception('invalid scenario.');
}
throw new \Exception('scenario not found.');
}
示例7: sendMail
public static function sendMail($mail, $servers = [], $mailingto = null)
{
$recipients = [];
foreach (Mail::parseAddressList(($mailing = $mailingto !== null) ? $mailingto : "{$mail->to},{$mail->cc},{$mail->bcc}") as $address) {
stripos($address[1], Mail::INTERNAL_HOST) === false and $recipients[strtolower("{$address['0']}@{$address['1']}")] = true;
}
if ($recipients) {
if (!$servers) {
throw new \Exception('SMTP: No servers available');
}
$recipients = array_keys($recipients);
$rawmessage = $mail->createMessage($mailing ? 2 : 1);
foreach ($servers as $server) {
try {
list($host, $port, $security) = extractServer($server[0], 25);
$smtp = new self($host, $port, $security);
$server[1] == '' || $smtp->auth($server[1], $server[2]);
$smtp->send($mail->sender_email, $recipients, $rawmessage);
$smtp->close();
return;
} catch (\Exception $e) {
$msg = "SMTP {$server['0']}: " . $e->getMessage();
}
}
throw new \Exception($msg);
}
}
示例8: send
public function send($data = null)
{
if ($this->ready_state !== 1) {
self::throw_error('Invalid state; Cannot send unopened request', E_RECOVERABLE_ERROR);
}
// Build the data string
if (!is_string($data) && $data !== null) {
if (is_array($data)) {
$data_arr = '';
foreach ($data as $name => $value) {
$data_arr[] = urlencode($name) . ' = ' . urlencode($value);
}
$data = implode('&', $data_arr);
} else {
self::throw_error('Invalid data parameter given; Expects string, array, or NULL', E_RECOVERABLE_ERROR);
}
}
// Build the request
$request = $this->method . ' ' . $this->url_info['path'] . ' HTTP/1.1' . CRLF;
$request .= 'Host: ' . $this->url_info['host'] . CRLF;
foreach ($this->headers as $name => $value) {
$request .= $name . ': ' . $value . CRLF;
}
$request .= CRLF . $data;
// Send the request
$response = '';
fputs($this->fh, $request);
while (!feof($this->fh)) {
$response .= fgets($this->fh, 128);
}
fclose($this->fh);
// Seperate the response
$response = explode(CRLF . CRLF, $response, 2);
$headers = explode(CRLF, $response[0]);
$this->response_body = $response[1];
// Parse the response status
$http = array_shift($headers);
preg_match('/^HTTP\\/[0-9.]+ ([0-9]{3}) (.*)$/', $http, $match);
$this->status = (int) $match[1];
$this->status_text = $match[2];
// Parse the headers
$parsed_headers = array();
foreach ($headers as $header) {
$header = explode(': ', $header, 2);
$parsed_headers[$header[0]] = $header[1];
}
$this->response_headers = $parsed_headers;
// Check for a location header
if (isset($this->response_headers['Location'])) {
$location = $this->response_headers;
$sub_request = new self();
$sub_request->__is_redirect($this->redirect_stack);
$sub_request->open($this->method, $location);
if ($sub_request->error_code) {
$this->error_code = $sub_request->error_code;
return false;
}
foreach ($this->headers as $name => $value) {
$sub_request->set_request_header($name, $value);
}
$sub_request->send($data);
$this->response_text = $sub_request->response_text;
$this->response_headers = $sub_request->get_all_response_headers();
$this->status_code = $sub_request->status_code;
$this->status_text = $sub_request->status_text;
}
// All done
$this->ready_state = 4;
return $this;
}
示例9: mail
public static function mail($to, $subject, $message)
{
$mail = new self($to, $subject, $message);
$mail->send();
}
示例10: sendSMS
static function sendSMS($arr_numbers, $smscontent)
{
try {
if (!is_array($arr_numbers)) {
$arr_numbers = array($arr_numbers);
}
if (count($arr_numbers) == 0) {
throw new Exception('Please specify Mobile Phone');
}
if (empty($smscontent)) {
throw new Exception('Please specify SMS content');
}
$obj_SMS = new self(self::CONST_USERNAME, self::CONST_PASSWORD, self::CONST_SENDERID);
foreach ($arr_numbers as $mobile_num) {
$obj_SMS->appendMobileNum($mobile_num);
}
$obj_SMS->setMessage($smscontent);
$ret_message = $obj_SMS->send();
if (strstr($ret_message, 'MsgID') === false) {
throw new Exception($ret_message);
}
} catch (Exception $e) {
return false;
}
return true;
}
示例11: test
/**
* Run a self test of the Zmsg class.
*
* @return boolean
* @todo See if assert returns
*/
public static function test()
{
$result = true;
$context = new ZMQContext();
$output = new ZMQSocket($context, ZMQ::SOCKET_DEALER);
$output->bind("inproc://zmsg_selftest");
$input = new ZMQSocket($context, ZMQ::SOCKET_ROUTER);
$input->connect("inproc://zmsg_selftest");
// Test send and receive of single-part message
$zmsgo = new self($output);
$zmsgo->body_set("Hello");
$result &= assert($zmsgo->body() == "Hello");
$zmsgo->send();
$zmsgi = new self($input);
$zmsgi->recv();
$result &= assert($zmsgi->parts() == 2);
$result &= assert($zmsgi->body() == "Hello");
echo $zmsgi;
// Test send and receive of multi-part message
$zmsgo = new self($output);
$zmsgo->body_set("Hello");
$zmsgo->wrap("address1", "");
$zmsgo->wrap("address2");
$result &= assert($zmsgo->parts() == 4);
echo $zmsgo;
$zmsgo->send();
$zmsgi = new self($input);
$zmsgi->recv();
$result &= assert($zmsgi->parts() == 5);
$zmsgi->unwrap();
$result &= assert($zmsgi->unwrap() == "address2");
$zmsgi->body_fmt("%s%s", 'W', "orld");
$result &= assert($zmsgi->body() == "World");
// Pull off address 1, check that empty part was dropped
$zmsgi->unwrap();
$result &= assert($zmsgi->parts() == 1);
// Check that message body was correctly modified
$part = $zmsgi->pop();
$result &= assert($part == "World");
$result &= assert($zmsgi->parts() == 0);
// Test load and save
$zmsg = new self();
$zmsg->body_set("Hello");
$zmsg->wrap("address1", "");
$zmsg->wrap("address2");
$result &= assert($zmsg->parts() == 4);
$fh = fopen(sys_get_temp_dir() . "/zmsgtest.zmsg", 'w');
$zmsg->save($fh);
fclose($fh);
$fh = fopen(sys_get_temp_dir() . "/zmsgtest.zmsg", 'r');
$zmsg2 = new self();
$zmsg2->load($fh);
assert($zmsg2->last() == $zmsg->last());
fclose($fh);
$result &= assert($zmsg2->parts() == 4);
echo $result ? "OK" : "FAIL", PHP_EOL;
return $result;
}
示例12: cronMinute
/**
* Cron job to read mails from queue and send them out
*/
public function cronMinute($item)
{
//! get real mailer backend ($core->mailer points to db queue backend)
// @codeCoverageIgnoreStart
if (empty(Core::$core->realmailer)) {
Core::log('C', L('Real mailer backend not configured!'));
}
// @codeCoverageIgnoreEnd
//! get items from database
$lastId = 0;
while ($row = DS::fetch('*', 'email_queue', 'id>?', '', 'id ASC', [$lastId])) {
$email = new self($row['data']);
$lastId = $row['id'];
try {
if (!$email->send(Core::$core->realmailer)) {
// @codeCoverageIgnoreStart
throw new \Exception('send() returned false');
}
DS::exec('DELETE FROM email_queue WHERE id=?;', [$row['id']]);
} catch (\Exception $e) {
Core::log('E', sprintf(L('Unable to send #%s from queue'), $row['id']) . ': ' . $e->getMessage());
}
// @codeCoverageIgnoreEnd
sleep(1);
}
}
示例13: send_data
public static function send_data()
{
global $DB, $CFG;
$log = array();
$me = new self();
$curl = new curl();
$courses;
$users;
$members;
$permission_read = $DB->get_record('config', array('name' => 'atypaxreportscourseenable'));
if ($permission_read->value == 1) {
$xml_path = $DB->get_record('config', array('name' => 'atypaxreportscoursepath'));
$xml = new SimpleXMLElement($me->prepare_path($xml_path->value, 'COFR'), NULL, TRUE);
$categories = $me->prepare_xml($xml, "rootcategories");
//print_r($categories);
if (empty($categories['categories'])) {
array_push($log, array('root_categories' => 'sin nuevas categorias de ciclo'));
} else {
array_push($log, array('root_categories' => $me->send($categories, "categorie", $curl)));
}
$categories = $me->prepare_xml($xml, "ciclocat");
//print_r($categories);
if (empty($categories['categories'])) {
array_push($log, array('ciclo_categories' => 'sin nuevas categorias padre'));
} else {
array_push($log, array('ciclo_categories' => $me->send($categories, "categorie", $curl)));
}
$categories = $me->prepare_xml($xml, "categories");
if (empty($categories['categories'])) {
array_push($log, array('categories' => 'sin nuevas categorias'));
} else {
array_push($log, array('categories' => $me->send($categories, "categorie", $curl)));
}
//$temxml = new SimpleXMLElement($me->prepare_path($xml_path->value,'MEMB'), NULL, TRUE);
$courses = $me->prepare_xml($xml, "course");
if (empty($courses['courses'])) {
array_push($log, array('courses' => 'sin cursos nuevos'));
} else {
array_push($log, array('courses' => $me->send($courses, "course", $curl)));
}
$xml = new SimpleXMLElement($me->prepare_path($xml_path->value, 'PRSN'), NULL, TRUE);
$users = $me->prepare_xml($xml, "user");
if (empty($users['users'])) {
array_push($log, array('users' => 'sin usuarios nuevos'));
} else {
array_push($log, array('users' => $me->send($users, "user", $curl)));
}
$xml = new SimpleXMLElement($me->prepare_path($xml_path->value, 'MEMB'), NULL, TRUE);
$members = $me->prepare_xml($xml, "member");
if (empty($members)) {
array_push($log, array('members' => 'Sin nuevas matriculas'));
} else {
foreach ($members as $member) {
if ($log['members'] == null) {
array_push($log, array('members' => $me->send($member, "member", $curl)));
} else {
$log['members'] = array_merge($log['members'], $me->send($member, "member", $curl));
}
}
}
}
return $log;
}
示例14: end
public static function end(ResponseBuilder &$res)
{
$helper = new self();
$helper->send($res);
exit(0);
}
示例15: newSeries
public static function newSeries($serial, $series)
{
$users = FavoritesModel::model()->where("`video_id`='{$serial->id}'")->findAll();
$to = "";
if (!$users) {
return False;
}
foreach ($users as $user) {
$model = UsersModel::model()->where("`id`='{$user->user_id}'")->findRow();
if ($model->email) {
$to .= $model->email . ", ";
}
}
$to = trim($to, ", ");
$mail = new self();
$mail->to = $to;
$mail->nameTo = "Everybody";
$mail->subject = "Новая серия " . $serial->en_name;
$mail->text = $mail->loadTemplate("new_series", array("serial_name" => $serial->en_name, "href" => "http://" . $_SERVER['HTTP_HOST'] . "/serials/" . $serial->seo_url, "series_name" => $series->name));
$mail->send();
}