本文整理汇总了PHP中Mailer::deliver方法的典型用法代码示例。如果您正苦于以下问题:PHP Mailer::deliver方法的具体用法?PHP Mailer::deliver怎么用?PHP Mailer::deliver使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mailer
的用法示例。
在下文中一共展示了Mailer::deliver方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: main
/**
* undocumented function
*
* todo: encryption
*
* @return void
* @access public
*/
function main()
{
$this->out('Calculating reports ..');
$reports = $this->Report->find('all');
if (empty($reports)) {
$this->out('Found 0 reports. Exiting.');
exit(1);
}
$Pgp = Common::getComponent('Pgp');
foreach ($reports as $report) {
$this->out('Processing report "' . $report['Report']['title'] . '" ..');
$conditions = array('ReportsUser.report_id' => $report['Report']['id']);
$frequency = $report['Report']['frequency'];
switch ($frequency) {
case 'daily':
$date = date('Y-m-d H:i', strtotime('-1 day'));
break;
case 'weekly':
$date = date('Y-m-d H:i', strtotime('-1 week'));
break;
case 'yearly':
$date = date('Y-m-d H:i', strtotime('-1 year'));
break;
}
// $conditions[] = "DATE_FORMAT(ReportsUser.last_sent, '%Y-%m-%d %H:%i') = '" . $date . "'";
$users = $this->ReportsUser->find('all', array('conditions' => $conditions, 'contain' => array('User'), 'order' => array('ReportsUser.created' => 'asc')));
$this->out('Found ' . count($users) . ' user(s) that need a report');
if (empty($users)) {
continue;
}
$name = ucfirst($report['Report']['frequency']) . ' Report "' . $report['Report']['title'] . '"';
foreach ($users as $user) {
$officeId = $user['User']['office_id'];
$query = $report['Report']['query'];
$query = r('%condition', 'AND Gift.office_id = "' . $officeId . '"', $query);
$results = $this->Transaction->query($query);
$content = $this->parseTemplate($report['Report']['view'], $results);
$attachment = $Pgp->encrypt(array('msg' => $content, 'recipient' => $user['User']['login']));
if (!$attachment) {
$this->out('There was a problem encrypting the report for ' . $user['User']['login']);
}
$this->ReportsUser->set(array('id' => $user['ReportsUser']['id'], 'last_sent' => date('Y-m-d H:i:s')));
$this->ReportsUser->save();
if (!Common::isDevelopment()) {
$options = array('mail' => array('to' => $user['User']['login'], 'subject' => $name, 'attachments' => array($attachment)), 'vars' => compact('content'));
Mailer::deliver('report', $options);
$this->out('Sent ' . $name . ' to ' . $user['User']['login']);
}
$Pgp->flush();
}
}
}
示例2: emailReceipt
/**
* Deliver mail receipt
* @param string $email
* @param string $authKey
* @return void
* @access public
*/
function emailReceipt($email, $authKey)
{
$emailSettings = array('vars' => array('keyData' => $authKey), 'mail' => array('to' => $email, 'subject' => Configure::read('App.name') . ': Your Tax Receipt'), 'store' => false);
Mailer::deliver('receipt', $emailSettings);
}
示例3: main
/**
* undocumented function
*
* @return void
* @access public
*/
function main()
{
$login = isset($this->args[0]) ? $this->args[0] : false;
if (empty($login) || $login == Configure::read('App.emails.guestAccount')) {
$this->out('Funny man ..');
exit(1);
}
$data = $this->User->find('first', array('conditions' => compact('login')));
if (!$data) {
$this->out('The user ' . $login . ' does not exist yet. Please choose an office for this user:');
$this->hr();
$this->out('Office for the new User:');
$officeOptions = $this->Office->find('list');
$ids = array_keys($officeOptions);
$names = array_values($officeOptions);
foreach ($names as $i => $name) {
$i++;
$this->out($i . '. ' . $name);
}
$validChoice = false;
do {
$choice = $this->in('Please choose a number: ');
if ($choice > count($officeOptions)) {
$this->out('This number is not valid, please retry.');
} else {
$validChoice = true;
}
} while (!$validChoice);
$data['User']['office_id'] = $ids[$choice - 1];
$this->hr();
$this->out('Salutation for the new user:');
while (empty($data['Contact']['salutation'])) {
$title = strtoupper($this->in('[M]r oder [Mr]s'));
switch ($title) {
case 'M':
$data['Contact']['salutation'] = 'mr';
break;
case 'Mr':
$data['Contact']['salutation'] = 'mrs';
break;
default:
$this->out('Your input is invalid. Please type in either [M] or [Mr].', true);
}
}
// @todo maybe add support for title (prof., dr., prof. dr., etc.)
$data['Contact']['email'] = $login;
while (true) {
$data['Contact']['fname'] = $this->in('First Name:');
$data['Contact']['lname'] = $this->in('Last Name:');
if ($this->validates($data, 'Contact')) {
break;
}
}
$data['User']['name'] = $data['Contact']['fname'] . ' ' . $data['Contact']['lname'];
$this->hr();
$data['User']['level'] = 'admin';
$data['User']['login'] = $login;
$this->Contact->create($data);
if (!$this->Contact->save()) {
return $this->out('Sorry, an error has occurred while saving the contact data');
}
$contactId = $this->Contact->getLastInsertId();
$data['User']['active'] = '1';
$data['User']['contact_id'] = $contactId;
$this->User->create();
} else {
$this->out('The user ' . $login . ' exists. Are you sure you want to reset the password for this user?');
while (empty($confirm)) {
$confirm = strtoupper($this->in('[Y]es or [N]o'));
switch ($confirm) {
case 'Y':
break;
case 'N':
$this->out('O.K. The script is terminated.');
exit(0);
break;
default:
$confirm = '';
$this->out('Your input is invalid, please type in either [Y] or [N].', true);
}
}
}
$this->hr();
$pwData = $this->User->generatePassword();
$password = $pwData[0];
$data['User']['password'] = $pwData[1];
$data['User']['repeat_password'] = $pwData[1];
if (!$this->User->save($data)) {
return $this->out('Sorry, an error has occurred while saving the user data.');
}
$officeUrl = Configure::read('App.domain');
$options = array('mail' => array('to' => $login, 'subject' => 'New Account for Greenpeace White Rabbit'), 'vars' => array('url' => $officeUrl, 'password' => $password));
if (!Common::isDevelopment()) {
Mailer::deliver('created_admin', $options);
//.........这里部分代码省略.........
示例4: sendNewAccountEmail
/**
* undocumented function
*
* @param string $data
* @param string $password
* @return void
* @access public
*/
function sendNewAccountEmail($password, $data)
{
$options = array('mail' => array('to' => $data['User']['login'], 'subject' => __('New Account for Greenpeace White Rabbit', true)), 'vars' => array('url' => Configure::read('App.domain'), 'password' => $password));
Mailer::deliver('created_admin', $options);
$managers = $this->find('office_managers', array('exclude_me' => true, 'office_id' => $data[__CLASS__]['office_id']));
foreach ($managers as $manager) {
$options = array('mail' => array('to' => $manager[__CLASS__]['login'], 'subject' => __('New Admin created in your office for Greenpeace White Rabbit', true)), 'vars' => array('url' => Configure::read('App.domain'), 'login' => $data[__CLASS__]['login'], 'creator' => User::get()));
Mailer::deliver('office_admin_note_for_new_user', $options);
}
}
示例5: refer
/**
* controller action for tellafriend feature
*
* @return void
* @access public
*/
function refer()
{
//render tellfriends page
if ($this->isGet()) {
return;
}
//Check whether email content is spam
$comment = array('comment_author' => '', 'comment_author_email' => $this->data['Tellfriend']['sender'], 'comment_content' => $this->data['Tellfriend']['content'], 'comment_type' => 'tell a friend');
$emailContentIsSpam = $this->Akismet->checkComment($comment);
//Verify recaptcha
$recaptchaVerified = true;
if ($this->data['tellafriend']['useRecaptcha'] == 1) {
$recaptchaVerified = $this->Recaptcha->valid($this->params['form']);
}
if ($emailContentIsSpam == 'true') {
echo $msg = 'Message content appears to be spam.';
exit;
} else {
if ($recaptchaVerified) {
$allowedCharInEmail = array('@', ',', '.', '-', '_');
App::import('Sanitize');
$this->data['Tellfriend']['receiver'] = Sanitize::paranoid($this->data['Tellfriend']['receiver'], $allowedCharInEmail);
$toEmail = explode(',', $this->data['Tellfriend']['receiver']);
array_walk($toEmail, 'trim');
$fromEmail = $this->data['Tellfriend']['sender'];
$saveData = $this->data;
$saveData['Tellfriend']['ip'] = $this->RequestHandler->getClientIP();
if ($this->Caplimit->checkCaps($toEmail, $fromEmail) == false) {
return $this->render('refer_not_allowed');
}
if ($this->Tellfriend->saveReference($saveData, $toEmail)) {
$appName = Configure::read('App.name');
foreach ($toEmail as $email) {
$emailSettings = array('vars' => array('message' => $this->data['Tellfriend']['content']), 'mail' => array('to' => $email, 'subject' => 'A Friend suggested you check out ' . $appName));
if (Mailer::deliver('tellfriend', $emailSettings)) {
$this->Tellfriend->saveField('sent', 1);
$msg = __('Your message has been sent to your friends.', true);
return $this->Message->add($msg, 'ok', true, $this->referer());
}
$msg = __('Your message was not sent due to an internal problem. Please try again.', true);
return $this->Message->add($msg, 'ok', true, $this->referer());
}
}
} else {
$msg = __('The characters you entered didn\'t match the word verification. Please try again.', true);
return $this->Message->add($msg, 'ok', true, $this->referer());
}
}
}