本文整理汇总了PHP中Email::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Email::save方法的具体用法?PHP Email::save怎么用?PHP Email::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Email
的用法示例。
在下文中一共展示了Email::save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: saveEmailAddress
/**
* @param string $emailAddress
* @return mixed if true integer otherwise null
*/
public static function saveEmailAddress($emailAddress)
{
$emailID = null;
$parseEmail = explode('@', strtolower(trim($emailAddress)));
if (count($parseEmail) == 2) {
$domain = Domain::model()->findByAttributes(array('name' => $parseEmail[1]));
if (!$domain) {
$domain = new Domain();
$domain->name = $parseEmail[1];
}
if ($domain->save()) {
$email = new Email();
$email->username = $parseEmail[0];
$email->domainID = $domain->ID;
if ($email->save()) {
$emailID = $email->ID;
} else {
if ($domain->isNewRecord) {
Domain::model()->deleteByPk($domain->ID);
}
}
}
}
return $emailID;
}
示例2: createEmail
public static function createEmail($id = '', $override = array())
{
global $timedate;
$time = mt_rand();
$name = 'SugarEmail';
$email = new Email();
$email->name = $name . $time;
$email->type = 'out';
$email->status = 'sent';
$email->date_sent = $timedate->to_display_date_time(gmdate("Y-m-d H:i:s", gmmktime() - 3600 * 24 * 2));
// Two days ago
if (!empty($id)) {
$email->new_with_id = true;
$email->id = $id;
}
foreach ($override as $key => $value) {
$email->{$key} = $value;
}
$email->save();
if (!empty($override['parent_id']) && !empty($override['parent_type'])) {
self::createEmailsBeansRelationship($email->id, $override['parent_type'], $override['parent_id']);
}
self::$_createdEmails[] = $email;
return $email;
}
示例3: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate()
{
$model = new Usuario();
// Uncomment the following line if AJAX validation is needed
$this->performAjaxValidation($model);
if (isset($_POST['Usuario'])) {
$model->attributes = $_POST['Usuario'];
$model->estatus_did = 1;
$model->tipoUsuario_did = 4;
$model->fechaCreacion_f = date("Y-d-m H:i:s");
$model->contrasena = md5($model->contrasena);
if (isset($_POST["noticias"])) {
$email = new Email();
$email->nombre = $model->nombre . " " . $model->apPaterno . " " . $model->apMaterno;
$email->direccion = $model->domCalle . " " . $model->domNo . " " . $model->domColonia;
$email->telefono = $model->telefono;
$email->correo = $model->correo;
$email->estatus_did = 1;
$email->fecha_f = date("Y-d-m");
$email->save();
}
if ($model->save()) {
$this->redirect(array('site/index'));
}
}
$this->render('create', array('model' => $model));
}
示例4: actionSend
public function actionSend()
{
if (Input::get('to') && Input::get('subject') && Input::get('message')) {
$to = Input::get('to');
$subject = Input::get('subject');
$message = Input::get('message');
if (empty($to) || empty($subject) || empty($message)) {
$data = array('success' => false, 'message' => 'Please fill out the form completely.');
echo json_encode($data);
exit;
}
$email = new Email();
$email->to = $to;
if ($email->save()) {
Mail::send('emails.main', ['text' => $message, 'host' => $_SERVER['HTTP_HOST'], 'id' => $email->id], function ($message) use($to, $subject) {
$message->to($to)->subject($subject);
});
if (count(Mail::failures())) {
$data = array('success' => false, 'message' => 'Message could not be sent.');
$email->delete();
echo json_encode($data);
exit;
}
$data = array('success' => true, 'message' => 'Thanks! We have received your message.');
echo json_encode($data);
} else {
$data = array('success' => false, 'message' => 'Message could not be sent.');
echo json_encode($data);
}
} else {
$data = array('success' => false, 'message' => 'Please fill out the form completely.');
echo json_encode($data);
}
exit;
}
示例5: Email
function send_email($module, $module_type, $printable, $file_name, $attach)
{
require_once 'modules/Emails/Email.php';
global $current_user, $mod_strings, $sugar_config;
//First Create e-mail draft
$email = new Email();
// set the id for relationships
$email->id = create_guid();
$email->new_with_id = true;
//subject
$email->name = $mod_strings['LBL_EMAIL_NAME'] . ' ' . $module->name;
//body
$email->description_html = $printable;
//type is draft
$email->type = "draft";
$email->status = "draft";
if (!empty($module->billing_contact_id) && $module->billing_contact_id != "") {
require_once 'modules/Contacts/Contact.php';
$contact = new Contact();
$contact->retrieve($module->billing_contact_id);
$email->parent_type = 'Contacts';
$email->parent_id = $contact->id;
if (!empty($contact->email1)) {
$email->to_addrs_emails = $contact->email1 . ";";
$email->to_addrs = $module->billing_contact_name . " <" . $contact->email1 . ">";
}
}
//team id
$email->team_id = $current_user->default_team;
//assigned_user_id
$email->assigned_user_id = $current_user->id;
//Save the email object
global $timedate;
$email->date_start = $timedate->to_display_date_time(gmdate($GLOBALS['timedate']->get_db_date_time_format()));
$email->save(FALSE);
$email_id = $email->id;
if ($attach) {
$note = new Note();
$note->modified_user_id = $current_user->id;
$note->created_by = $current_user->id;
$note->name = $file_name;
$note->parent_type = 'Emails';
$note->parent_id = $email_id;
$note->file_mime_type = 'application/pdf';
$note->filename = $file_name;
$note->save();
rename($sugar_config['upload_dir'] . 'attachfile.pdf', $sugar_config['upload_dir'] . $note->id);
}
//redirect
if ($email_id == "") {
echo "Unable to initiate Email Client";
exit;
} else {
header("Location: index.php?action=Compose&module=Emails&return_module=" . $module_type . "&return_action=DetailView&return_id=" . $_REQUEST['record'] . "&recordId=" . $email_id);
}
}
示例6: setUp
public function setUp()
{
SugarTestHelper::setUp('beanFiles');
SugarTestHelper::setUp('beanList');
SugarTestHelper::setUp('current_user');
$this->account = SugarTestAccountUtilities::createAccount();
$this->contact = SugarTestContactUtilities::createContact();
$this->email = SugarTestEmailUtilities::createEmail();
$this->opportunity = SugarTestOpportunityUtilities::createOpportunity('', $this->account);
$this->contact->account_id = $this->account->id;
$this->contact->save();
$this->opportunity->load_relationship('contacts');
$this->opportunity->contacts->add($this->contact);
$this->email->parent_id = $this->contact->id;
$this->email->parent_type = $this->contact->module_name;
$this->email->save();
if (isset($GLOBALS['app'])) {
$this->application = $GLOBALS['app'];
}
$GLOBALS['app'] = new SugarApplication();
$GLOBALS['app']->controller = new SugarController();
}
示例7: linkLeadToEmail
/**
* Link the Lead to the Email from which the lead was created
* Also set the assigned user to current user and mark email as read.
* TODO: This logic is brought over from LeadFormBase->handleSave() - need refactoring to use Link2?
*
* @param $emailId
* @param $leadId
*/
protected function linkLeadToEmail($emailId, $leadId)
{
global $current_user;
$email = new Email();
$email->retrieve($emailId);
$email->parent_type = 'Leads';
$email->parent_id = $leadId;
$email->assigned_user_id = $current_user->id;
$email->status = 'read';
$email->save();
$email->load_relationship('leads');
$email->leads->add($leadId);
}
示例8: send_email
public function send_email($dummy)
{
$rules = array('from_name' => 'required|max:128', 'from_email' => 'required|email|max:255', 'subject' => 'required|max:128', 'emailbody' => 'required');
$validator = Validator::make(Input::all(), $rules);
if ($validator->fails()) {
return Response::json(array('validation' => $validator->messages()->toArray()));
} else {
$from_name = Input::get('from_name');
$from_email = Input::get('from_email');
$selected = Input::get('to');
$subject = Input::get('subject');
$emailbody = Input::get('emailbody');
$from = $from_name . ' (' . $from_email . ')';
$recipients = Subscriber::whereIn('email', $selected)->where('active', '=', 1)->get();
$email = new Email();
$email->from = $from;
$email->subject = $subject;
$email->message = $emailbody;
$email->save();
$email_id = $email->id;
$numrecipients = $recipients->count();
$numsent = 0;
foreach ($recipients as $key => $recipient) {
$tracker = new Tracker();
$tracker->subscriber_id = $recipient->id;
$tracker->email_id = $email_id;
$tracker->save();
$tracker_id = $tracker->id;
$tracker_url = URL::to('tracker/' . $tracker_id);
$unsubscriber_url = URL::to('unsubscribe/' . $tracker_id);
$subscriber = $recipient;
$data = array('emailbody' => $emailbody, 'tracker' => $tracker_url, 'unsubscribe' => $unsubscriber_url, 'subscriber' => $subscriber);
$to_email = $subscriber->email;
$to_name = $subscriber->first_name . ' ' . $subscriber->last_name;
$issent = Mail::send('emails.sub-emails', $data, function ($message) use($from_email, $from_name, $to_email, $to_name, $subject) {
$message->from($from_email, $from_name)->to($to_email, $to_name)->subject($subject);
});
if ($issent) {
$numsent += 1;
} else {
$tracker->bounced = 1;
$tracker->save();
}
}
if ($numsent == $numrecipients) {
return Response::json(array('success' => 'Your email was successfully sent to <b>' . $numsent . '</b> subscribers out of the ' . $numrecipients . ' subscribers you selected. <b>Rejoice!</b>'));
} else {
return Response::json(array('success' => 'Your email was successfully sent to <b>' . $numsent . '</b> subscribers out of the ' . $numrecipients . 'All bounces have been logged.'));
}
}
}
示例9: queue_to_email
public static function queue_to_email($to_email, $to_name, $subject, $text, $html)
{
$email = new Email();
$email->set('user_id', $user->id);
$email->set('subject', $subject);
$email->set('text_body', $text);
$email->set('html_body', $html);
$email->set('to_email', $to_email);
$email->set('to_name', $to_name);
$email->set('queue_date', date("Y-m-d H:i:s"));
$email->set('status', 'queued');
$email->save();
//send it right away.
//$email->send();
}
示例10: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate()
{
$model = new Email();
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if (isset($_POST['Email'])) {
$model->attributes = $_POST['Email'];
$model->estatus_did = 1;
$model->fecha_f = date("Y-d-m");
if ($model->save()) {
$this->redirect(array('view', 'id' => $model->id));
}
}
$this->render('create', array('model' => $model));
}
示例11: queue_to_email
public static function queue_to_email($to_email, $to_name, $subject, $text, $html, $user_id = 0)
{
$email = new Email();
$email->set('user_id', $user_id);
$email->set('subject', $subject);
$email->set('text_body', $text);
$email->set('html_body', $html);
$email->set('to_email', $to_email);
$email->set('to_name', $to_name);
$email->set('queue_date', date("Y-m-d H:i:s"));
$email->set('status', 'queued');
$email->save();
//send it right away, or queue it.
if (!(defined("QUEUE_EMAIL") && QUEUE_EMAIL)) {
$email->send();
}
return $email;
}
示例12: announce
public function announce()
{
$content = Input::get('content');
$content = nl2br($content);
$users = User::all();
foreach ($users as $user) {
$input = array('content' => $content, 'user' => $user);
Mail::send('emails.announce', $input, function ($message) use($user) {
$message->to("{$user->email}")->subject('hackGFS - Announcement from ' . Sentry::getUser()->first_name . ' ' . Sentry::getUser()->last_name);
});
}
$user = Sentry::getUser();
$email = new Email();
$email->email = 'hackgfs.2015@gmail.com';
$email->company = 'hackGFS';
$email->user_id = $user->id;
$email->content = $content;
$email->save();
return Redirect::back();
}
示例13: testSaveNewEmailWithParent
public function testSaveNewEmailWithParent()
{
$email = new Email();
$email->type = 'out';
$email->status = 'sent';
$email->from_addr_name = $email->cleanEmails("sender@domain.eu");
$email->to_addrs_names = $email->cleanEmails("to@domain.eu");
$email->cc_addrs_names = $email->cleanEmails("cc@domain.eu");
// set a few parent info to test the scenario
$email->parent_type = 'Accounts';
$email->parent_id = $this->_account->id;
$email->fetched_row['parent_type'] = 'Accounts';
$email->fetched_row['parent_id'] = $this->_account->id;
$email->save();
$this->assertNotNull($email->id, 'Null email id');
$this->email_id = $email->id;
// ensure record is inserted into emails_beans table
$query = "select count(*) as cnt from emails_beans eb WHERE eb.bean_id = '{$this->_account->id}' AND eb.bean_module = 'Accounts' AND eb.email_id = '{$email->id}' AND eb.deleted=0";
$result = $GLOBALS['db']->query($query);
$count = $GLOBALS['db']->fetchByAssoc($result);
$this->assertEquals(1, $count['cnt'], 'Incorrect emails_beans count');
}
示例14: setUp
public function setUp()
{
global $current_user, $currentModule, $timedate;
$mod_strings = return_module_language($GLOBALS['current_language'], "Contacts");
$current_user = SugarTestUserUtilities::createAnonymousUser();
$this->outbound_id = uniqid();
$time = date('Y-m-d H:i:s');
$em = new Email();
$em->name = 'tst_' . uniqid();
$em->type = 'inbound';
$em->intent = 'pick';
$em->date_sent = $timedate->to_display_date_time(gmdate("Y-m-d H:i:s", gmmktime() + 3600 * 24 * 2));
//Two days from today
$em->save();
$this->em1 = $em;
$n = new Note();
$n->name = 'tst_' . uniqid();
$n->filename = 'file_' . uniqid();
$n->parent_type = 'Emails';
$n->parent_id = $this->em1->id;
$n->save();
$this->note1 = $n;
}
示例15: testSaveNewFolder
/**
* Save a SugarFolder
*/
public function testSaveNewFolder()
{
$this->markTestIncomplete('This test takes to long to run');
return;
global $current_user, $app_strings;
$email = new Email();
$email->type = 'out';
$email->status = 'sent';
$email->from_addr_name = $email->cleanEmails("sender@domain.eu");
$email->to_addrs_names = $email->cleanEmails("to@domain.eu");
$email->cc_addrs_names = $email->cleanEmails("cc@domain.eu");
$email->save();
$_REQUEST["emailUIAction"] = "getSingleMessageFromSugar";
$_REQUEST["uid"] = $email->id;
$_REQUEST["mbox"] = "";
$_REQUEST['ieId'] = "";
ob_start();
require "modules/Emails/EmailUIAjax.php";
$jsonOutput = ob_get_contents();
ob_end_clean();
$meta = json_decode($jsonOutput);
$this->assertRegExp("/.*cc@domain.eu.*/", $meta->meta->email->cc);
}