本文整理汇总了PHP中SpoonFilter::isEmail方法的典型用法代码示例。如果您正苦于以下问题:PHP SpoonFilter::isEmail方法的具体用法?PHP SpoonFilter::isEmail怎么用?PHP SpoonFilter::isEmail使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SpoonFilter
的用法示例。
在下文中一共展示了SpoonFilter::isEmail方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: parse
/**
* Parse the data into the template
*/
private function parse()
{
// form was sent?
if ($this->URL->getParameter('sent') == 'true') {
// show message
$this->tpl->assign('unsubscribeIsSuccess', true);
// hide form
$this->tpl->assign('unsubscribeHideForm', true);
}
// unsubscribe was issued for a specific group/address
if (SpoonFilter::isEmail($this->email) && FrontendMailmotorModel::existsGroup($this->group)) {
// unsubscribe the address from this group
if (FrontendMailmotorModel::unsubscribe($this->email, $this->group)) {
// hide form
$this->tpl->assign('unsubscribeHideForm', true);
// show message
$this->tpl->assign('unsubscribeIsSuccess', true);
} else {
// show message
$this->tpl->assign('unsubscribeHasError', true);
}
}
// parse the form
$this->frm->parse($this->tpl);
}
示例2: validateForm
/**
* Validate the form
*/
protected function validateForm()
{
if ($this->frm->isSubmitted()) {
$this->frm->cleanupFields();
$fields = $this->frm->getFields();
$fields['email']->isFilled(BL::err('FieldIsRequired'));
if ($this->frm->isCorrect()) {
//--Get the mail
$mailing = BackendMailengineModel::get($this->id);
//--Get the template
$template = BackendMailengineModel::getTemplate($mailing['template_id']);
//--Create basic mail
$text = BackendMailengineModel::createMail($mailing, $template);
$mailing['from_email'] = $template['from_email'];
$mailing['from_name'] = html_entity_decode($template['from_name']);
$mailing['reply_email'] = $template['reply_email'];
$mailing['reply_name'] = html_entity_decode($template['reply_name']);
$emails = explode(',', $fields['email']->getValue());
if (!empty($emails)) {
foreach ($emails as $email) {
$email = trim($email);
if (\SpoonFilter::isEmail($email)) {
//--Send test mailing
BackendMailengineModel::sendMail(html_entity_decode($mailing['subject']), $text, $email, 'Test Recepient', $mailing);
}
}
}
//--Redirect
\SpoonHTTP::redirect(BackendModel::createURLForAction('index', $this->module) . "&id=" . $this->id . "&report=TestEmailSend");
}
}
$this->frm->parse($this->tpl);
}
示例3: setEmaUsu
public function setEmaUsu($emailUsuario)
{
if (SpoonFilter::isEmail($emailUsuario) && SpoonFilter::isSmallerThan(50, strlen($emailUsuario))) {
$this->emaUsu = $emailUsuario;
} else {
echo "Ha introducido un valor Incorrecto para el correo";
exit;
}
}
示例4: validateForm
/**
* Validates the given data
*/
private function validateForm()
{
// validate
if (!\SpoonFilter::isEmail($this->email)) {
$this->output(self::ERROR);
}
if ($this->email == '') {
$this->output(self::ERROR);
}
}
示例5: validateForm
/**
* Validate the form
*/
private function validateForm()
{
// is the form submitted?
if ($this->frm->isSubmitted()) {
// cleanup the submitted fields, ignore fields that were added by hackers
$this->frm->cleanupFields();
// validate fields
$this->frm->getField('email')->isFilled(BL::err('EmailIsRequired'));
// get addresses
$addresses = (array) explode(',', $this->frm->getField('email')->getValue());
// loop addresses
foreach ($addresses as $email) {
// validate email
if (!\SpoonFilter::isEmail(trim($email))) {
// add error if needed
$this->frm->getField('email')->addError(BL::err('ContainsInvalidEmail'));
// stop looking
break;
}
}
$this->frm->getField('groups')->isFilled(BL::err('ChooseAtLeastOneGroup'));
// no errors?
if ($this->frm->isCorrect()) {
// build item
$item = $this->frm->getValues();
$item['source'] = BL::lbl('Manual');
$item['created_on'] = BackendModel::getUTCDate('Y-m-d H:i:s');
// loop the groups
foreach ($item['groups'] as $group) {
foreach ($addresses as $email) {
BackendMailmotorCMHelper::subscribe(trim($email), $group);
}
}
// trigger event
BackendModel::triggerEvent($this->getModule(), 'after_add_address', array('item' => $item));
// everything is saved, so redirect to the overview
$this->redirect(BackendModel::createURLForAction('Addresses') . (!empty($this->groupId) ? '&group_id=' . $this->groupId : '') . '&report=added');
}
}
}
示例6: execute
/**
* Execute the action
*/
public function execute()
{
parent::execute();
$fromEmail = \SpoonFilter::getPostValue('mailer_from_email', null, '');
$fromName = \SpoonFilter::getPostValue('mailer_from_name', null, '');
$toEmail = \SpoonFilter::getPostValue('mailer_to_email', null, '');
$toName = \SpoonFilter::getPostValue('mailer_to_name', null, '');
$replyToEmail = \SpoonFilter::getPostValue('mailer_reply_to_email', null, '');
$replyToName = \SpoonFilter::getPostValue('mailer_reply_to_name', null, '');
// init validation
$errors = array();
// validate
if ($fromEmail == '' || !\SpoonFilter::isEmail($fromEmail)) {
$errors['from'] = BL::err('EmailIsInvalid');
}
if ($toEmail == '' || !\SpoonFilter::isEmail($toEmail)) {
$errors['to'] = BL::err('EmailIsInvalid');
}
if ($replyToEmail == '' || !\SpoonFilter::isEmail($replyToEmail)) {
$errors['reply'] = BL::err('EmailIsInvalid');
}
// got errors?
if (!empty($errors)) {
$this->output(self::BAD_REQUEST, array('errors' => $errors), 'invalid fields');
} else {
$message = \Swift_Message::newInstance('Test')->setFrom(array($fromEmail => $fromName))->setTo(array($toEmail => $toName))->setReplyTo(array($replyToEmail => $replyToName))->setBody(BL::msg('TestMessage'), 'text/plain');
$transport = \Common\Mailer\TransportFactory::create(\SpoonFilter::getPostValue('mailer_type', array('smtp', 'mail'), 'mail'), \SpoonFilter::getPostValue('smtp_server', null, ''), \SpoonFilter::getPostValue('smtp_port', null, ''), \SpoonFilter::getPostValue('smtp_username', null, ''), \SpoonFilter::getPostValue('smtp_password', null, ''), \SpoonFilter::getPostValue('smtp_secure_layer', null, ''));
$mailer = \Swift_Mailer::newInstance($transport);
try {
if ($mailer->send($message)) {
$this->output(self::OK, null, '');
} else {
$this->output(self::ERROR, null, 'unknown');
}
} catch (\Exception $e) {
$this->output(self::ERROR, null, $e->getMessage());
}
}
}
示例7: rcptTo
/**
* RCPT TO command, function that shows the host the recipients's email address.
*
* @return bool
* @param string $email The recipient's e-mail address.
*/
public function rcptTo($email)
{
// check input
if (!SpoonFilter::isEmail($email)) {
throw new SpoonEmailException('No valid email given for ' . __METHOD__);
}
// push MAIL FROM command
$this->say('RCPT TO: <' . $email . '>');
// smtp code 250 means success
return $this->repliedCode === 250 ? true : false;
}
示例8: validateForm
/**
* Validate the form
*/
private function validateForm()
{
if ($this->frm->isSubmitted()) {
$this->frm->cleanupFields();
// shorten the fields
$txtName = $this->frm->getField('name');
$txtEmail = $this->frm->getField('email');
$ddmMethod = $this->frm->getField('method');
$txtSuccessMessage = $this->frm->getField('success_message');
$txtIdentifier = $this->frm->getField('identifier');
$emailAddresses = (array) explode(',', $txtEmail->getValue());
// validate fields
$txtName->isFilled(BL::getError('NameIsRequired'));
$txtSuccessMessage->isFilled(BL::getError('SuccessMessageIsRequired'));
if ($ddmMethod->isFilled(BL::getError('NameIsRequired')) && $ddmMethod->getValue() == 'database_email') {
$error = false;
// check the addresses
foreach ($emailAddresses as $address) {
$address = trim($address);
if (!SpoonFilter::isEmail($address)) {
$error = true;
break;
}
}
// add error
if ($error) {
$txtEmail->addError(BL::getError('EmailIsInvalid'));
}
}
// identifier
if ($txtIdentifier->isFilled()) {
// invalid characters
if (!SpoonFilter::isValidAgainstRegexp('/^[a-zA-Z0-9\\.\\_\\-]+$/', $txtIdentifier->getValue())) {
$txtIdentifier->setError(BL::getError('InvalidIdentifier'));
} elseif (BackendFormBuilderModel::existsIdentifier($txtIdentifier->getValue(), $this->id)) {
$txtIdentifier->setError(BL::getError('UniqueIdentifier'));
}
}
if ($this->frm->isCorrect()) {
// build array
$values['name'] = $txtName->getValue();
$values['method'] = $ddmMethod->getValue();
$values['email'] = $ddmMethod->getValue() == 'database_email' ? serialize($emailAddresses) : null;
$values['success_message'] = $txtSuccessMessage->getValue(true);
$values['identifier'] = $txtIdentifier->isFilled() ? $txtIdentifier->getValue() : BackendFormBuilderModel::createIdentifier();
$values['edited_on'] = BackendModel::getUTCDate();
// insert the item
$id = (int) BackendFormBuilderModel::update($this->id, $values);
// trigger event
BackendModel::triggerEvent($this->getModule(), 'after_edit', array('item' => $values));
// everything is saved, so redirect to the overview
$this->redirect(BackendModel::createURLForAction('index') . '&report=edited&var=' . urlencode($values['name']) . '&highlight=row-' . $id);
}
}
}
示例9: testIsEmail
public function testIsEmail()
{
$this->assertTrue(SpoonFilter::isEmail('erik@spoon-library.be'));
$this->assertTrue(SpoonFilter::isEmail('erik+bauffman@spoon-library.be'));
$this->assertTrue(SpoonFilter::isEmail('erik-bauffman@spoon-library.be'));
$this->assertTrue(SpoonFilter::isEmail('erik.bauffman@spoon-library.be'));
$this->assertTrue(SpoonFilter::isEmail('a.osterhaus@erasmusnc.nl'));
$this->assertTrue(SpoonFilter::isEmail('asmonto@umich.edu'));
$this->assertFalse(SpoonFilter::isEmail(array()));
$this->assertFalse(SpoonFilter::isEmail(array('foo@example.com')));
}
示例10: isEmail
/**
* Checks this field for a valid e-mail address.
*
* @return bool
* @param string[optional] $error The error message to set.
*/
public function isEmail($error = null)
{
// filled
if ($this->isFilled()) {
// post/get data
$data = $this->getMethod(true);
// validate
if (!isset($data[$this->attributes['name']]) || !SpoonFilter::isEmail($data[$this->attributes['name']])) {
if ($error !== null) {
$this->setError($error);
}
return false;
}
return true;
}
// has error
if ($error !== null) {
$this->setError($error);
}
return false;
}
示例11: loadForm
/**
* Load the form
*/
private function loadForm()
{
// create form
$this->frm = new FrontendForm('commentsForm');
$this->frm->setAction($this->frm->getAction() . '#' . FL::act('Comment'));
// init vars
$author = Cookie::exists('comment_author') ? Cookie::get('comment_author') : null;
$email = Cookie::exists('comment_email') && \SpoonFilter::isEmail(Cookie::get('comment_email')) ? Cookie::get('comment_email') : null;
$website = Cookie::exists('comment_website') && \SpoonFilter::isURL(Cookie::get('comment_website')) ? Cookie::get('comment_website') : 'http://';
// create elements
$this->frm->addText('author', $author)->setAttributes(array('required' => null));
$this->frm->addText('email', $email)->setAttributes(array('required' => null, 'type' => 'email'));
$this->frm->addText('website', $website, null);
$this->frm->addTextarea('message')->setAttributes(array('required' => null));
$this->frmContact = new FrontendForm('contact', null, 'post');
$this->frmContact->addText('name')->setAttribute('class', 'form-control');
$this->frmContact->addText('emailContact', null, 255, 'form-control');
//->setAttribute('class', 'form-control');
$this->frmContact->addText('phone')->setAttribute('class', 'form-control');
$this->frmContact->addTextarea('messageContact', Language::lbl('ProductMoreInfo') . ' ' . $this->record['title'])->setAttribute('class', 'form-control');
}
示例12: loadForm
/**
* Load the form
*/
private function loadForm()
{
// create form
$this->frm = new FrontendForm('subscriptionsForm');
$this->frm->setAction($this->frm->getAction() . '#' . FL::act('Subscribe'));
// init vars
$name = Cookie::exists('subscription_author') ? Cookie::get('subscription_author') : null;
$email = Cookie::exists('subscription_email') && \SpoonFilter::isEmail(Cookie::get('subscription_email')) ? Cookie::get('subscription_email') : null;
// create elements
$this->frm->addText('name', $name, 255, 'form-control')->setAttributes(array('required' => null));
$this->frm->addText('email', $email, 255, 'form-control')->setAttributes(array('required' => null, 'type' => 'email'));
}
示例13: execute
/**
* Execute the action
*/
public function execute()
{
parent::execute();
// mailer type
$mailerType = SpoonFilter::getPostValue('mailer_type', array('smtp', 'mail'), 'mail');
// create new SpoonEmail-instance
$email = new SpoonEmail();
$email->setTemplateCompileDirectory(BACKEND_CACHE_PATH . '/compiled_templates');
// send via SMTP
if ($mailerType == 'smtp') {
// get settings
$SMTPServer = SpoonFilter::getPostValue('smtp_server', null, '');
$SMTPPort = SpoonFilter::getPostValue('smtp_port', null, '');
$SMTPUsername = SpoonFilter::getPostValue('smtp_username', null, '');
$SMTPPassword = SpoonFilter::getPostValue('smtp_password', null, '');
if ($SMTPServer == '') {
$this->output(self::BAD_REQUEST, null, BL::err('ServerIsRequired'));
}
if ($SMTPPort == '') {
$this->output(self::BAD_REQUEST, null, BL::err('PortIsRequired'));
}
try {
// set server and connect with SMTP
$email->setSMTPConnection($SMTPServer, $SMTPPort, 10);
} catch (SpoonEmailException $e) {
$this->output(self::ERROR, null, $e->getMessage());
}
// set authentication if needed
if ($SMTPUsername != '' && $SMTPPassword != '') {
$email->setSMTPAuth($SMTPUsername, $SMTPPassword);
}
}
$fromEmail = SpoonFilter::getPostValue('mailer_from_email', null, '');
$fromName = SpoonFilter::getPostValue('mailer_from_name', null, '');
$toEmail = SpoonFilter::getPostValue('mailer_to_email', null, '');
$toName = SpoonFilter::getPostValue('mailer_to_name', null, '');
$replyToEmail = SpoonFilter::getPostValue('mailer_reply_to_email', null, '');
$replyToName = SpoonFilter::getPostValue('mailer_reply_to_name', null, '');
// validate
if ($fromEmail == '' || !SpoonFilter::isEmail($fromEmail)) {
$this->output(self::BAD_REQUEST, null, BL::err('EmailIsInvalid'));
}
if ($toEmail == '' || !SpoonFilter::isEmail($toEmail)) {
$this->output(self::BAD_REQUEST, null, BL::err('EmailIsInvalid'));
}
if ($replyToEmail == '' || !SpoonFilter::isEmail($replyToEmail)) {
$this->output(self::BAD_REQUEST, null, BL::err('EmailIsInvalid'));
}
// set some properties
$email->setFrom($fromEmail, $fromName);
$email->addRecipient($toEmail, $toName);
$email->setReplyTo($replyToEmail, $replyToName);
$email->setSubject('Test');
$email->setHTMLContent(BL::msg('TestMessage'));
$email->setCharset(SPOON_CHARSET);
try {
if ($email->send()) {
$this->output(self::OK, null, '');
} else {
$this->output(self::ERROR, null, 'unknown');
}
} catch (SpoonEmailException $e) {
$this->output(self::ERROR, null, $e->getMessage());
}
}
示例14: updateCustomFields
/**
* Updates the custom fields for a given group. Accepts an optional third parameter $email that will update the values for that e-mail.
*
* @param array $fields The fields.
* @param int $groupId The group to update.
* @param string[optional] $email The email you want to update the custom fields for.
* @return int
*/
public static function updateCustomFields($fields, $groupId, $email = null)
{
// get DB
$db = BackendModel::getDB(true);
// set values to update
$values = array();
// no email address set means we just update the custom fields (ie adding new ones)
if (!empty($email) && SpoonFilter::isEmail($email)) {
// set custom fields values
$values['custom_fields'] = serialize($fields);
// update field values for this email
$db->update('mailmotor_addresses_groups', $values, 'email = ? AND group_id = ?', array($email, (int) $groupId));
}
// fetch array keys if $fields isn't a boolean
if ($fields !== false && !isset($fields[0])) {
$fields = array_keys($fields);
}
// overwrite custom fields so we only have the keys
$values['custom_fields'] = serialize($fields);
// update the field values for this e-mail address
return (int) $db->update('mailmotor_groups', $values, 'id = ?', array((int) $groupId));
}
示例15: addEmail
/**
* Adds an email to the queue.
*
* @param string $subject The subject for the email.
* @param string $template The template to use.
* @param array[optional] $variables Variables that should be assigned in the email.
* @param string[optional] $toEmail The to-address for the email.
* @param string[optional] $toName The to-name for the email.
* @param string[optional] $fromEmail The from-address for the mail.
* @param string[optional] $fromName The from-name for the mail.
* @param string[optional] $replyToEmail The replyto-address for the mail.
* @param string[optional] $replyToName The replyto-name for the mail.
* @param bool[optional] $queue Should the mail be queued?
* @param int[optional] $sendOn When should the email be send, only used when $queue is true.
* @param bool[optional] $isRawHTML If this is true $template will be handled as raw HTML, so no parsing of $variables is done.
* @param string[optional] $plainText The plain text version.
* @param array[optional] $attachments Paths to attachments to include.
* @return int The id of the inserted mail.
*/
public static function addEmail($subject, $template, array $variables = null, $toEmail = null, $toName = null, $fromEmail = null, $fromName = null, $replyToEmail = null, $replyToName = null, $queue = false, $sendOn = null, $isRawHTML = false, $plainText = null, array $attachments = null)
{
$subject = (string) strip_tags($subject);
$template = (string) $template;
// set defaults
$to = BackendModel::getModuleSetting('core', 'mailer_to');
$from = BackendModel::getModuleSetting('core', 'mailer_from');
$replyTo = BackendModel::getModuleSetting('core', 'mailer_reply_to');
// set recipient/sender headers
$email['to_email'] = $toEmail === null ? (string) $to['email'] : $toEmail;
$email['to_name'] = $toName === null ? (string) $to['name'] : $toName;
$email['from_email'] = $fromEmail === null ? (string) $from['email'] : $fromEmail;
$email['from_name'] = $fromName === null ? (string) $from['name'] : $fromName;
$email['reply_to_email'] = $replyToEmail === null ? (string) $replyTo['email'] : $replyToEmail;
$email['reply_to_name'] = $replyToName === null ? (string) $replyTo['name'] : $replyToName;
// validate
if (!SpoonFilter::isEmail($email['to_email'])) {
throw new BackendException('Invalid e-mail address for recipient.');
}
if (!SpoonFilter::isEmail($email['from_email'])) {
throw new BackendException('Invalid e-mail address for sender.');
}
if (!SpoonFilter::isEmail($email['reply_to_email'])) {
throw new BackendException('Invalid e-mail address for reply-to address.');
}
// build array
$email['subject'] = SpoonFilter::htmlentitiesDecode($subject);
if ($isRawHTML) {
$email['html'] = $template;
} else {
$email['html'] = self::getTemplateContent($template, $variables);
}
if ($plainText !== null) {
$email['plain_text'] = $plainText;
}
$email['created_on'] = BackendModel::getUTCDate();
// init var
$matches = array();
// get internal links
preg_match_all('|href="/(.*)"|i', $email['html'], $matches);
// any links?
if (!empty($matches[0])) {
// init vars
$search = array();
$replace = array();
// loop the links
foreach ($matches[0] as $key => $link) {
$search[] = $link;
$replace[] = 'href="' . SITE_URL . '/' . $matches[1][$key] . '"';
}
// replace
$email['html'] = str_replace($search, $replace, $email['html']);
}
// init var
$matches = array();
// get internal urls
preg_match_all('|src="/(.*)"|i', $email['html'], $matches);
// any links?
if (!empty($matches[0])) {
// init vars
$search = array();
$replace = array();
// loop the links
foreach ($matches[0] as $key => $link) {
$search[] = $link;
$replace[] = 'src="' . SITE_URL . '/' . $matches[1][$key] . '"';
}
// replace
$email['html'] = str_replace($search, $replace, $email['html']);
}
// attachments added
if (!empty($attachments)) {
// add attachments one by one
foreach ($attachments as $attachment) {
// only add existing files
if (SpoonFile::exists($attachment)) {
$email['attachments'][] = $attachment;
}
}
// serialize :)
if (!empty($email['attachments'])) {
//.........这里部分代码省略.........