本文整理汇总了PHP中Email::create方法的典型用法代码示例。如果您正苦于以下问题:PHP Email::create方法的具体用法?PHP Email::create怎么用?PHP Email::create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Email
的用法示例。
在下文中一共展示了Email::create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
public function run()
{
$faker = Faker::create();
foreach (range(1, 10) as $index) {
Email::create([]);
}
}
示例2: buildEmail
/**
* @param null $from
* @param null $to
* @param null $subject
* @param null $body
* @param null $bounceHandlerURL
* @param null $cc
* @param null $bcc
* @return Email
*/
public function buildEmail($from = null, $to = null, $subject = null, $body = null, $bounceHandlerURL = null, $cc = null, $bcc = null)
{
$env = 'dev';
if (defined('SS_ENVIRONMENT_TYPE')) {
$env = SS_ENVIRONMENT_TYPE;
}
$email = Email::create();
if ($env == 'dev') {
$to = defined('DEV_EMAIL_TO') ? DEV_EMAIL_TO : Config::inst()->get('Email', 'admin_email');
}
if (!is_null($from)) {
$email->setFrom($from);
}
if (!is_null($to)) {
$email->setTo($to);
}
if (!is_null($subject)) {
$email->setSubject($subject);
}
if (!is_null($body)) {
$email->setBody($body);
}
if (!is_null($cc)) {
$email->setCc($cc);
}
if (!is_null($bcc)) {
$email->setBcc($bcc);
}
return $email;
}
示例3: sendVerificationEmail
/**
* Send verification email to member.
*/
public function sendVerificationEmail()
{
$validation_link = Controller::join_links(Director::absoluteURL('Security/validate-email'), $this->owner->VerificationString);
$site_config = SiteConfig::current_site_config();
$site_title = $site_config->Title;
$admin_email = Config::inst()->get('Email', 'admin_email');
$email_template_data = array('Member' => $this->owner, 'ValidationLink' => $validation_link, 'SiteConfig' => $site_config);
$email_subject = _t('MemberEmailVerification.VERIFICATIONEMAILSUBJECT', "{site_title} Email Verification", array('site_title' => $site_title));
if (!$admin_email) {
// Fallback to a placeholder admin email if Email.admin_email is not set
$admin_email = 'admin@domain.com';
}
$sender_email = self::get_formatted_email($site_title, $admin_email);
$recipient_email = $this->owner->Email;
$email_to_recipient = Email::create($sender_email, $recipient_email, $email_subject);
$email_to_recipient->setTemplate('VerificationEmail');
$email_to_recipient->populateTemplate($email_template_data);
$email_status = $email_to_recipient->send();
// Return true if the email was successfully sent
// Mailer::email will return `true` or an array if the email was successfully sent
if ($email_status === true || is_array($email_status)) {
return true;
}
return false;
}
开发者ID:jordanmkoncz,项目名称:silverstripe-memberemailverification,代码行数:28,代码来源:EmailVerificationMemberExtension.php
示例4: create
public function create()
{
if ($_POST) {
$id = $this->email->create();
if ($id) {
showMessage(lang('Template created', 'cmsemail'));
if ($this->input->post('action') == 'tomain') {
pjax('/admin/components/cp/cmsemail/index');
} else {
pjax('/admin/components/cp/cmsemail/edit/' . $id . '#settings');
}
} else {
showMessage($this->email->errors, '', 'r');
}
} else {
\CMSFactory\assetManager::create()->registerScript('email', TRUE)->setData('settings', $this->email->getSettings())->renderAdmin('create');
}
}
示例5: __construct
public function __construct()
{
$this->emailer = Email::create();
$config = $this->config();
$this->emailer->setFrom($config->from);
$this->emailer->setTo($config->to);
$this->emailer->setSubject($config->subject);
$this->emailer->setTemplate($config->template);
}
示例6: sendEmail
public function sendEmail()
{
$from = "The Hub Event Management <no-reply@dpc.nsw.gov.au>";
$to = $this->getManagerEmail();
$subject = "New event registration: " . $this->getTitle();
$email = Email::create();
$email->setFrom($from)->setTo($to)->setSubject($subject)->setTemplate('EventNotification')->populateTemplate(ArrayData::create(array('Name' => $this->Name, 'Email' => $this->Email, 'Title' => $this->getTitle(), 'StartDate' => $this->Time()->StartDate, 'StartTime' => $this->Time()->StartTime, 'EndDate' => $this->Time()->EndDate, 'EndTime' => $this->Time()->EndTime)));
$email->send();
}
示例7: __sendEmail
private function __sendEmail()
{
$email = Email::create();
$email->setSenderEmailAddress($this->getSenderEmail);
$email->setFrom($this->getFromEmail(), $this->getFromName());
$email->setReplyToEmailAddress($this->getFromEmail());
$email->setRecipients($this->getReceipients());
$email->setSubject($this->getSubject());
$email->setTextPlain($this->getBody());
return $email->validate() && $email->send();
}
示例8: emailReport
public function emailReport($expired, $expiring, $newMembers)
{
$email = Email::create();
$to = 'secretary@nzlarps.org, treasurer@nzlarps.org';
$email->setTo($to);
$email->setBcc('it@nzlarps.org');
$email->setSubject("NZLarps daily membership report");
$content = $email->customise(new ArrayData(array('NewMembers' => $newMembers, 'ExpiredMembers' => $expired, 'ExpiryingMembers' => $expiring)))->renderWith('ReportEmail');
$email->setBody($content);
$email->send();
echo '<p>Report has been sent</p>';
}
示例9: buildEmail
/**
* @param string $template
* @param string $subject
*
* @return Email
*/
private function buildEmail($template, $subject)
{
$from = ShopConfig::config()->email_from ? ShopConfig::config()->email_from : Email::config()->admin_email;
$to = $this->order->getLatestEmail();
$checkoutpage = CheckoutPage::get()->first();
$completemessage = $checkoutpage ? $checkoutpage->PurchaseComplete : '';
$email = Email::create();
$email->setTemplate($template);
$email->setFrom($from);
$email->setTo($to);
$email->setSubject($subject);
$email->populateTemplate(array('PurchaseCompleteMessage' => $completemessage, 'Order' => $this->order, 'BaseURL' => Director::absoluteBaseURL()));
return $email;
}
示例10: onAfterWrite
/**
*
*/
public function onAfterWrite()
{
if (!$this->IsSpam) {
/** @var Email $mail */
$mail = Email::create();
$to = $this->Receiver;
$this->Target = self::$to[$this->Receiver];
$mail->setTo($to);
$mail->setSubject('Contact form submission ' . $this->Subject);
$mail->setFrom($this->Email);
$mail->setTemplate('ContactFormPost');
$mail->populateTemplate($this);
$mail->send();
} else {
$this->delete();
}
}
示例11: createmarkers
/**
* Creates new marker accounts from a list of emails and sends emails to new markers.
*
*/
function createmarkers()
{
if ($this->input->post('emails')) {
$this->load->library('validation');
$rules['emails'] = 'valid_emails|required';
$fields['emails'] = 'referree emails';
$this->validation->set_fields($fields);
$this->validation->set_rules($rules);
$this->validation->set_message('valid_emails', 'All email addresses entered into %s must be valid, seperated by commas');
if ($this->validation->run() === TRUE) {
$emails = explode(',', $this->input->post('emails'));
$this->load->model('marker');
$this->load->model('email');
foreach ($emails as $email) {
$marker = new Marker();
$marker->setKey($email);
$password = $this->_createPassword();
$marker->set('password', $marker->makePass($password));
if ($marker->create()) {
$emailData['email'] = $email;
$emailData['password'] = $password;
$msg = $this->load->view('email/new_marker', $emailData, TRUE);
$subject = 'Next step in your application';
$emailToStore = new Email();
$emailToStore->set('sender', 'recruitment@exambuff.co.uk');
$emailToStore->set('receiver', $email);
$emailToStore->set('subject', $subject);
$emailToStore->set('message', $msg);
$emailToStore->create();
$viewData['messages'][] = "Successfully created marker account for {$email} with password {$password}";
} else {
}
}
}
}
if ($this->validation->error_string) {
$viewData['errors'][] = $this->validation->error_string;
}
$viewData['token'] = $this->_token();
$this->load->view('control/create_markers', $viewData);
}
示例12: requireDefaultRecords
/**
* We are abusing requireDefaultRecords to run this on dev/build.
*/
public function requireDefaultRecords()
{
parent::requireDefaultRecords();
// verbose messages
DB::alteration_message('Searching for environment configuration for ' . Director::absoluteURL('/'), 'created');
// get the config based on the URL (URL is key)
$config = $this->prepConfig($this->config()->get('environments'), Director::absoluteURL('/'));
// only run if everything is fine
if (!is_array($config) || empty($config)) {
DB::alteration_message('No configuration found.', 'created');
} elseif (!file_exists('../' . $config['filename'])) {
DB::alteration_message('No CHANGELOG.md-file found.', 'created');
} else {
DB::alteration_message($config['environment_name'] . ' identified.', 'created');
// get the information in the database for the last release notification
$record = self::get()->count() == 0 ? new self() : self::get()->first();
// load the changelog and remove the first 4 lines
$changelog = trim(preg_replace('/^(.*\\n){4}/', '', file_get_contents('../' . $config['filename'])));
// check if the CHANGELOG.md file has been changed since the last run
if ($changelog == '') {
DB::alteration_message('No CHANGELOG found.', 'created');
} elseif (md5($changelog) != md5($record->Changelog)) {
// remove the former releases from the changelog
$release = trim(str_replace($record->Changelog, '', $changelog));
// email the changelog out
foreach ($config['recipients'] as $recipient) {
Email::create($config['from'], $recipient, $config['subject'], sprintf("%s (%s)\n\n%s", $config['environment_name'], $config['url'], $release))->sendPlain();
DB::alteration_message($recipient . ' notified', 'created');
}
// save the new changelog to ensure we aren't re-running this in the next step
$record->Changelog = $changelog;
}
// say welcome :)
if (!$record->ID) {
DB::alteration_message('Install of FriendsOfSilverStripe/release-notifications');
}
$record->write();
}
}
示例13: email_to_img
public static function email_to_img($email, $font_size = 13)
{
$exists = Email::where('email', '=', $email)->first();
if (!$exists) {
//create image
$width = imagefontwidth($font_size) * strlen($email);
$height = imagefontheight($font_size);
$im = imagecreate($width, $height);
$bg = imagecolorallocate($im, 255, 255, 255);
$textcolor = imagecolorallocate($im, 0, 0, 0);
imagestring($im, 5, 0, 0, $email, $textcolor);
//get image contents
ob_start();
imagepng($im);
$contents = ob_get_contents();
ob_end_clean();
imagedestroy($im);
$image_code = base64_encode($contents);
Email::create(array('email' => $email, 'image_code' => $image_code));
return $image_code;
}
return $exists->image_code;
}
示例14: success
/**
* Controller action that handles the "success" page
* @param $r SS_HTTPRequest
* @return SSViewer
*/
public function success(SS_HTTPRequest $r)
{
try {
$speakers = $this->presentation->Speakers()->exclude(array('MemberID' => $this->presentation->CreatorID));
$this->presentation->markReceived()->write();
foreach ($speakers as $speaker) {
$e = Email::create()->setTo($speaker->getEmail())->setUserTemplate('presentation-speaker-notification')->populateTemplate(array('RecipientMember' => $speaker->Member(), 'Presentation' => $this->presentation, 'Speaker' => $speaker, 'Creator' => $this->presentation->Creator(), 'EditLink' => Director::makeRelative($speaker->EditLink($this->presentation->ID)), 'ReviewLink' => Director::makeRelative($speaker->ReviewLink($this->presentation->ID)), 'PasswordLink' => Director::absoluteBaseURL() . '/lostpassword', 'Link' => Director::absoluteBaseURL() . Director::makeRelative($this->presentation->EditLink())))->send();
}
// Email the creator
Email::create()->setTo($this->presentation->Creator()->Email)->setUserTemplate('presentation-creator-notification')->populateTemplate(array('Creator' => $this->presentation->Creator(), 'Summit' => $this->presentation->Summit(), 'Link' => Director::absoluteBaseURL() . Director::makeRelative($this->presentation->EditLink()), 'PasswordLink' => Director::absoluteBaseURL() . '/lostpassword'))->send();
return $this->renderWith(array('PresentationPage_success', 'PresentationPage'), $this->parent);
} catch (EntityValidationException $ex1) {
SS_Log::log($ex1->getMessage(), SS_Log::ERR);
Form::messageForForm('PresentationForm_PresentationForm', $ex1->getMessages(), 'bad');
return Controller::curr()->redirect($this->presentation->EditLink());
} catch (Exception $ex) {
SS_Log::log($ex->getMessage(), SS_Log::ERR);
return $this->httpError(404);
}
}
示例15: sprintf
if ($_REQUEST['id'] && !($email = Email::lookup($_REQUEST['id']))) {
$errors['err'] = sprintf(__('%s: Unknown or invalid ID.'), __('email'));
}
if ($_POST) {
switch (strtolower($_POST['do'])) {
case 'update':
if (!$email) {
$errors['err'] = sprintf(__('%s: Unknown or invalid'), __('email'));
} elseif ($email->update($_POST, $errors)) {
$msg = sprintf(__('Successfully updated %s'), __('this email'));
} elseif (!$errors['err']) {
$errors['err'] = sprintf(__('Error updating %s. Try again!'), __('this email'));
}
break;
case 'create':
if ($id = Email::create($_POST, $errors)) {
$msg = sprintf(__('Successfully added %s'), Format::htmlchars($_POST['name']));
$_REQUEST['a'] = null;
} elseif (!$errors['err']) {
$errors['err'] = sprintf(__('Unable to add %s. Correct error(s) below and try again.'), __('this email'));
}
break;
case 'mass_process':
if (!$_POST['ids'] || !is_array($_POST['ids']) || !count($_POST['ids'])) {
$errors['err'] = sprintf(__('You must select at least %s'), __('one email'));
} else {
$count = count($_POST['ids']);
$sql = 'SELECT count(dept_id) FROM ' . DEPT_TABLE . ' dept ' . ' WHERE email_id IN (' . implode(',', db_input($_POST['ids'])) . ') ' . ' OR autoresp_email_id IN (' . implode(',', db_input($_POST['ids'])) . ')';
list($depts) = db_fetch_row(db_query($sql));
if ($depts > 0) {
$errors['err'] = __('One or more of the selected emails is being used by a department. Remove association first!');