本文整理汇总了PHP中ValidateEmail函数的典型用法代码示例。如果您正苦于以下问题:PHP ValidateEmail函数的具体用法?PHP ValidateEmail怎么用?PHP ValidateEmail使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ValidateEmail函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: check_parameters_mail
function check_parameters_mail($type, $mail_sender, $name_sender, $mail_receiver, $subject, $message)
{
$error = '';
// Check sender's name
if ($type == 'contact' && !$name_sender) {
$error .= 'Vous devez entrer un nom.<br />';
}
// Check sender's email
if (!$mail_sender) {
$error .= 'Vous devez entrer une adresse mail pour l\'expéditeur.<br />';
}
if ($mail_sender && !ValidateEmail($mail_sender)) {
$error .= 'L\'adresse mail de l\'expéditeur n\'est pas valide.<br />';
}
// Check the receiver's email
if (!$mail_receiver) {
$error .= 'Vous devez entrer une adresse mail pour le destinataire.<br />';
}
if ($mail_receiver && !ValidateEmail($mail_receiver)) {
$error .= 'L\'adresse mail du destinaire n\'est pas valide.<br />';
}
// Check message (length)
if ($type == 'contact' && (!$message || strlen($message) < 10)) {
$error .= "Veuillez entrer un message. Il doit faire au minimum 10 caractères.<br />";
}
return $error;
}
示例2: check_parameters_mail
function check_parameters_mail($type, $mail_sender, $name_sender, $mail_receiver, $subject, $messagebody)
{
$message['message'] = '';
$message['class'] = 'danger';
// Check sender's name
if ($type == 'contact' && !$name_sender) {
$message['message'] .= _t('CONTACT_ENTER_NAME') . '<br />';
}
// Check sender's email
if (!$mail_sender) {
$message['message'] .= _t('CONTACT_ENTER_SENDER_MAIL') . '<br />';
}
if ($mail_sender && !ValidateEmail($mail_sender)) {
$message['message'] .= _t('CONTACT_SENDER_MAIL_INVALID') . '<br />';
}
// Check the receiver's email
if (!$mail_receiver) {
$message['message'] .= _t('CONTACT_ENTER_RECEIVER_MAIL') . '<br />';
}
if ($mail_receiver && !ValidateEmail($mail_receiver)) {
$message['message'] .= _t('CONTACT_RECEIVER_MAIL_INVALID') . '<br />';
}
// Check message (length)
if ($type == 'contact' && (!$messagebody || strlen($messagebody) < 10)) {
$message['message'] .= _t('CONTACT_ENTER_MESSAGE') . '<br />';
}
// If no errors, we inform of success!
if ($message['message'] == '') {
$message['class'] = 'success';
}
return $message;
}
示例3: ValidateDnsEmail
function ValidateDnsEmail($Value, $Field = '')
{
if ($Value === NULL) {
return True;
}
// + required
$Result = ValidateEmail($Value, $Field);
if ($Result !== True) {
return 'ValidateEmail';
}
list($User, $Host) = explode('@', $Value);
$MxHosts = array();
$Result = getmxrr($Host, $MxHosts);
return $Result;
}
示例4: sendWelcomeEmail
/**
* Send welcome email to user.
*
* @param int $UserID
* @param string $Password
* @param string $RegisterType
* @param array|null $AdditionalData
* @throws Exception
*/
public function sendWelcomeEmail($UserID, $Password, $RegisterType = 'Add', $AdditionalData = null)
{
$Session = Gdn::session();
$Sender = $this->getID($Session->UserID);
$User = $this->getID($UserID);
if (!ValidateEmail($User->Email)) {
return;
}
$AppTitle = Gdn::config('Garden.Title');
$Email = new Gdn_Email();
$Email->subject(sprintf(t('[%s] Welcome Aboard!'), $AppTitle));
$Email->to($User->Email);
$emailTemplate = $Email->getEmailTemplate();
$Data = [];
$Data['User'] = arrayTranslate((array) $User, ['UserID', 'Name', 'Email']);
$Data['Sender'] = arrayTranslate((array) $Sender, ['Name', 'Email']);
$Data['Title'] = $AppTitle;
if (is_array($AdditionalData)) {
$Data = array_merge($Data, $AdditionalData);
}
$Data['EmailKey'] = valr('Attributes.EmailKey', $User);
$message = '<p>' . formatString(t('Hello {User.Name}!'), $Data) . ' ';
$message .= $this->getEmailWelcome($RegisterType, $User, $Data, $Password);
// Add the email confirmation key.
if ($Data['EmailKey']) {
$emailUrlFormat = '{/entry/emailconfirm,exurl,domain}/{User.UserID,rawurlencode}/{EmailKey,rawurlencode}';
$url = formatString($emailUrlFormat, $Data);
$message .= '<p>' . t('You need to confirm your email address before you can continue.') . '</p>';
$emailTemplate->setButton($url, t('Confirm My Email Address'));
} else {
$emailTemplate->setButton(externalUrl('/'), t('Access the Site'));
}
$emailTemplate->setMessage($message);
$emailTemplate->setTitle(t('Welcome Aboard!'));
$Email->setEmailTemplate($emailTemplate);
try {
$Email->send();
} catch (Exception $e) {
if (debug()) {
throw $e;
}
}
}
示例5: sendWelcomeEmail
/**
* Send welcome email to user.
*
* @param $UserID
* @param $Password
* @param string $RegisterType
* @param null $AdditionalData
* @throws Exception
*/
public function sendWelcomeEmail($UserID, $Password, $RegisterType = 'Add', $AdditionalData = null)
{
$Session = Gdn::session();
$Sender = $this->getID($Session->UserID);
$User = $this->getID($UserID);
if (!ValidateEmail($User->Email)) {
return;
}
$AppTitle = Gdn::config('Garden.Title');
$Email = new Gdn_Email();
$Email->subject(sprintf(t('[%s] Welcome Aboard!'), $AppTitle));
$Email->to($User->Email);
$Data = array();
$Data['User'] = arrayTranslate((array) $User, array('UserID', 'Name', 'Email'));
$Data['Sender'] = arrayTranslate((array) $Sender, array('Name', 'Email'));
$Data['Title'] = $AppTitle;
if (is_array($AdditionalData)) {
$Data = array_merge($Data, $AdditionalData);
}
$Data['EmailKey'] = valr('Attributes.EmailKey', $User);
// Check for the new email format.
if (($EmailFormat = t("EmailWelcome{$RegisterType}", '#')) != '#') {
$Message = formatString($EmailFormat, $Data);
} else {
$Message = sprintf(t('EmailWelcome'), $User->Name, $Sender->Name, $AppTitle, ExternalUrl('/'), $Password, $User->Email);
}
// Add the email confirmation key.
if ($Data['EmailKey']) {
$Message .= "\n\n" . FormatString(t('EmailConfirmEmail', self::DEFAULT_CONFIRM_EMAIL), $Data);
}
$Message = $this->_addEmailHeaderFooter($Message, $Data);
$Email->message($Message);
$Email->send();
}
示例6: ValidateEmail
// Check email
function ValidateEmail($value)
{
$regex = "/^([a-zA-Z0-9])+([\.a-zA-Z0-9_-])*@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-]+)*\.([a-zA-Z]{2,6})$/";
if($value == "") {
return false;
} else {
$string = preg_replace($regex, "", $value);
}
return empty($string) ? true : false;
}
if(!$text)
{
$error .= "Введите email";
}
if($text && !ValidateEmail($text))
{
$error .= "Введите корректный email";
}
//
if(!$error)
{
$subject ="Новая подписка!";
$message ="На сайте vitastretta.ru оформлена новая подписка!\n\nE-mail: ".$text."";
$mail = mail("paperdavid@gmail.com", $subject, $message,
"From: ".$name." <".$text."> "."Reply-To: ".$text." "." X-Mailer: PHP/" . phpversion());
if($mail)
{
echo 'OK';
示例7: foreach
}
$error = '';
foreach ($_POST as $key => $value) {
$_POST[$key] = stripslashes(trim($value));
if ($formFields[$key]['mandatory'] == 1) {
// Mandatory?
$value = stripslashes(trim($_POST[$key]));
if ($formFields[$key]['validation']['basic'] == 1) {
// Basic Validation
if (!$value) {
$error .= $formFields[$key]['errors']['none'] . '<br />';
}
}
if ($formFields[$key]['validation']['email'] == 1) {
// E-Mail Validation
if (!ValidateEmail($value)) {
$error .= $formFields[$key]['errors']['invalid'] . '<br />';
}
}
if ($formFields[$key]['validation']['min_chars'] > 0) {
// Minimum Chars
if (strlen($value) < $formFields[$key]['validation']['min_chars']) {
$error .= str_replace('[min_chars]', $formFields[$key]['validation']['min_chars'], $formFields[$key]['errors']['min_chars']) . '<br />';
}
}
}
}
if (USE_CAPTCHA == 1) {
$security_code = trim(strtolower($_POST['security_code']));
if ($security_code == '') {
$error .= $form_notifications['security_code_e'];
示例8: elseif
continue;
} elseif ($key === 'firm') {
$first_title = 'Производитель: ';
} elseif ($key === 'count') {
$first_title = 'Количество: ';
} elseif ($key === 'price') {
$first_title = 'Цена: ';
} elseif ($key === 'totalPrice') {
continue;
}
$message2 .= '<div style="clear: both; float: left; width: 45%; margin-right: 5%;">' . $first_title . '</div><div style="float: left; width: 50%;">' . $value . '</div>';
$message2 .= '</div>';
}
$message2 .= '</div>';
}
$message2 .= '<div style="text-align: center;">Итоговая цена: <span style="color: #22aba6; margin-bottom: 20px;">' . $total_price . '</span> рублей</div>';
$message2 .= "</div></body></html>";
if (!ValidateEmail($email)) {
$error = 'Your email is wrong!';
}
$message = wordwrap($message, 70);
if (!$error) {
$mail = mail($email, $subject, $message, "From: " . $name . " <" . $email . ">\r\n" . "Reply-To: " . $email . "\r\n" . "Content-type: text/html; charset=utf-8 \r\n" . "X-Mailer: PHP/" . phpversion());
$mail2 = mail($siteEmail, $subject, $message2, "From: " . $name . " <" . $email . ">\r\n" . "Reply-To: " . $email . "\r\n" . "Content-type: text/html; charset=utf-8 \r\n" . "X-Mailer: PHP/" . phpversion());
if ($mail && $mail2) {
echo 'ok';
}
} else {
echo '<div class="bg-error">' . $error . '</div>';
}
}
示例9: trim
if (!$mail->ValidateAddress($email)) {
$msg = 'You must specify a valid email address.';
return false;
}
return true;
}
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$name = trim($_POST['name']);
$phone = trim($_POST['phone']);
$email = trim($_POST['email']);
$message = trim($_POST['message']);
$data = array();
if (Validate($name, $phone, $email, $message)) {
require_once 'inc/phpmailer.php';
$mail = new PHPMailer();
if (ValidateEmail($mail, $email)) {
$email_body = '';
$email_body = $email_body . 'Name: ' . $name . '<br>';
$email_body = $email_body . 'Phone: ' . $phone . '<br>';
$email_body = $email_body . 'Email: ' . $email . '<br>';
$email_body = $email_body . 'Message: ' . $message . '<br>';
$mail->isSMTP();
$mail->Host = 'smtp.sendgrid.net';
$mail->SMTPAuth = true;
$mail->Username = SD_USERNAME;
$mail->Password = SD_PASSWORD;
$mail->SMTPSecure = 'tls';
$mail->Port = 587;
$mail->SetFrom($email, $name);
$address = 'renaissance@jecrc.ac.in';
$mail->AddAddress($address, 'Renaissance');
示例10: foreach
// Check all fields are populated
foreach ($params as $param) {
if (isset($_POST[$param]) && $_POST[$param] != "") {
$details[$param] = $_POST[$param];
setcookie($param, $_POST[$param], time() + 60 * 60 * 24 * 30);
} else {
if ($param != "giftWrapped") {
$detailsChecked = false;
$error[$param] = "Required field";
}
}
}
// Validate email
if (isset($details["email"])) {
$details["email"] = RemoveExtraChars($details["email"]);
if (!ValidateEmail($details["email"])) {
$error["email"] = "Email is not valid, please enter a valid email.";
$detailsChecked = false;
}
}
// Validate phone number
if (isset($details["contactNumber"])) {
$details["contactNumber"] = RemoveExtraChars($details["contactNumber"]);
}
// Validate credit card number
if (isset($details["cardNumber"]) && $details["cardNumber"] != "") {
$details["cardNumber"] = RemoveExtraChars($details["cardNumber"]);
$check = ValidateCard($details["cardNumber"]);
if ($check !== false) {
$details["cardType"] = $check;
} else {
示例11: switch
if (GetValue($Param, $this->Data['MyMeta'])) {
$Params[] = $this->Data['MyMeta'][$Param];
}
}
switch ($this->Data['MetaSpec'][$MetaI]['type']) {
case 'text':
$MetaV = Gdn_Format::Text($MetaV);
$Picasa = '';
$Flickr = '';
if ($this->Data['MetaSpec'][$MetaI]['social'] == 'picasa') {
$Picasa = '<input type="hidden" class="picsa" value="' . $MetaV . '" />';
}
if ($this->Data['MetaSpec'][$MetaI]['social'] == 'flickr') {
$Flickr = '<input type="hidden" class="flickr" value="' . $MetaV . '" />';
}
if (ValidateEmail($MetaV)) {
$MetaV = Email($MetaV);
} else {
if (ValidateWebAddress($MetaV) && preg_match('`\\.(jpg|jpeg|gif|png)$`i', $MetaV)) {
$MetaV = Anchor(Img($MetaV, $MetaV), $MetaV);
} else {
if (ValidateWebAddress($MetaV)) {
$LabelDefault = Gdn_Format::Text(GetValue('labeldefault', $this->Data['MetaSpec'][$MetaI]));
$Params = array_merge(array($this->User->Name, $this->Data['MetaSpec'][$MetaI]['name']), $Params);
$MetaV = '<a href="' . $MetaV . '">' . vsprintf(T('MyMeta.' . $MetaI . '.Label', $LabelDefault ? $LabelDefault : '%2$s'), $Params) . '</a>';
} else {
if ($this->Data['MetaSpec'][$MetaI]['urlformat'] && ValidateWebAddress($this->Data['MetaSpec'][$MetaI]['urlformat'])) {
$LabelDefault = Gdn_Format::Text(GetValue('labeldefault', $this->Data['MetaSpec'][$MetaI]));
$Params = array_merge(array($this->User->Name, $this->Data['MetaSpec'][$MetaI]['name']), $Params);
$MetaV = '<a href="' . str_replace('[id]', $MetaV, $this->Data['MetaSpec'][$MetaI]['urlformat']) . '">' . vsprintf(T('MyMeta.' . $MetaI . '.Label', $LabelDefault ? $LabelDefault : '%2$s'), $Params) . '</a>';
}
示例12: session_start
include_once '/objects/objects.php';
if (!isset($_SESSION)) {
session_start();
}
$err = "";
$hienthi = "dangky";
if (isset($_GET['do']) && $_GET['do'] == 'reg') {
if ($_POST['displayname'] != "") {
if ($_POST['username'] != "") {
if (strlen(trim($_POST['username'])) > 5) {
if ($_POST['email'] != "") {
if ($_POST['pass'] != "") {
if (strlen(trim($_POST['pass'])) > 5) {
if ($_POST['pass'] == $_POST['repass']) {
if (ValidateEmail($_POST['email'])) {
$taikhoan = new TaiKhoan();
$taikhoan->Email = $_POST['email'];
$taikhoan->TenDangNhap = $_POST['username'];
$taikhoan->MatKhau = $_POST['pass'];
$taikhoan->TenHienThi = $_POST['displayname'];
$taikhoan->IP = $_SERVER['REMOTE_ADDR'];
$taikhoan->NgayDangKy = time();
$r = $taikhoan->DangKy();
if ($r > 0) {
$hienthi = "thanhcong";
$_SESSION['taikhoan'] = serialize(TaiKhoan::LayTaiKhoan($taikhoan->TenDangNhap));
}
if ($r == -1) {
$err = "Tên đăng nhập đã có người sử dụng!";
} else {
示例13: isset
$error_url = '';
$error = '';
$mysql_server = 'localhost';
$mysql_database = 'oos1';
$mysql_table = 'asc_admin';
$mysql_username = 'root';
$mysql_password = '';
$eol = "\n";
$max_filesize = isset($_POST['filesize']) ? $_POST['filesize'] * 1024 : 1024000;
$boundary = md5(uniqid(time()));
$header = 'From: ' . $mailfrom . $eol;
$header .= 'Reply-To: ' . $mailfrom . $eol;
$header .= 'MIME-Version: 1.0' . $eol;
$header .= 'Content-Type: multipart/mixed; boundary="' . $boundary . '"' . $eol;
$header .= 'X-Mailer: PHP v' . phpversion() . $eol;
if (!ValidateEmail($mailfrom)) {
$error .= "The specified email address is invalid!\n<br>";
}
if (!empty($error)) {
$errorcode = file_get_contents($error_url);
$replace = "##error##";
$errorcode = str_replace($replace, $error, $errorcode);
echo $errorcode;
exit;
}
$internalfields = array("submit", "reset", "send", "filesize", "formid", "captcha_code", "recaptcha_challenge_field", "recaptcha_response_field", "g-recaptcha-response");
$message .= $eol;
$message .= "IP Address : ";
$message .= $_SERVER['REMOTE_ADDR'];
$message .= $eol;
foreach ($_POST as $key => $value) {
示例14: stripslashes
$name = stripslashes($_POST['name']);
$email = trim($_POST['email']);
$message = stripslashes($_POST['message']);
$phone = stripslashes($_POST['phone']);
$answer = trim($_POST['answer']);
$verificationanswer = "6";
// plz change edit your human answer
$from = $email;
$to = $replyto;
$error = '';
$headers = "From: {$name} <" . $email . "> \n";
$headers .= "Reply-to:" . $email . "\n";
$headers .= 'MIME-Version: 1.0' . "\r\n";
$headers = "Content-Type: text/html; charset=utf-8\n" . $headers;
// Checks Name Field
if (!$name || !$email || $email && !ValidateEmail($email) || $answer != $verificationanswer || !$message || strlen($message) < 1) {
$error .= 'Please fill the required fields correctly.<br />';
}
if (!$error) {
$messages .= "Name: {$name} <br>";
$messages .= "Email: {$email} <br>";
$messages .= "Message: {$message} <br>";
$mail = mail($to, $subject, $messages, $headers);
if ($mail) {
echo 'OK';
if ($autorespond == "yes") {
include "autoresponde.php";
}
}
} else {
echo '<div class="error">' . $error . '</div>';
示例15: sendWelcomeEmail
/**
* Send welcome email to user.
*
* @param $UserID
* @param $Password
* @param string $RegisterType
* @param null $AdditionalData
* @throws Exception
*/
public function sendWelcomeEmail($UserID, $Password, $RegisterType = 'Add', $AdditionalData = null)
{
$Session = Gdn::session();
$Sender = $this->getID($Session->UserID);
$User = $this->getID($UserID);
if (!ValidateEmail($User->Email)) {
return;
}
$AppTitle = Gdn::config('Garden.Title');
$Email = new Gdn_Email();
$Email->subject(sprintf(t('[%s] Welcome Aboard!'), $AppTitle));
$Email->to($User->Email);
$emailTemplate = $Email->getEmailTemplate();
$Data = array();
$Data['User'] = arrayTranslate((array) $User, array('UserID', 'Name', 'Email'));
$Data['Sender'] = arrayTranslate((array) $Sender, array('Name', 'Email'));
$Data['Title'] = $AppTitle;
if (is_array($AdditionalData)) {
$Data = array_merge($Data, $AdditionalData);
}
$Data['EmailKey'] = valr('Attributes.EmailKey', $User);
$message = '<p>' . formatString(t('Hello {User.Name}!'), $Data) . ' ';
switch ($RegisterType) {
case 'Connect':
$message .= formatString(t('You have successfully connected to {Title}.'), $Data) . ' ' . t('Find your account information below.') . '<br></p>' . '<p>' . sprintf(t('%s: %s'), t('Username'), val('Name', $User)) . '<br>' . formatString(t('Connected With: {ProviderName}'), $Data) . '</p>';
break;
case 'Register':
$message .= formatString(t('You have successfully registered for an account at {Title}.'), $Data) . ' ' . t('Find your account information below.') . '<br></p>' . '<p>' . sprintf(t('%s: %s'), t('Username'), val('Name', $User)) . '<br>' . sprintf(t('%s: %s'), t('Email'), val('Email', $User)) . '</p>';
break;
default:
$message .= sprintf(t('%s has created an account for you at %s.'), val('Name', $Sender), $AppTitle) . ' ' . t('Find your account information below.') . '<br></p>' . '<p>' . sprintf(t('%s: %s'), t('Email'), val('Email', $User)) . '<br>' . sprintf(t('%s: %s'), t('Password'), $Password) . '</p>';
}
// Add the email confirmation key.
if ($Data['EmailKey']) {
$emailUrlFormat = '{/entry/emailconfirm,exurl,domain}/{User.UserID,rawurlencode}/{EmailKey,rawurlencode}';
$url = formatString($emailUrlFormat, $Data);
$message .= '<p>' . t('You need to confirm your email address before you can continue.') . '</p>';
$emailTemplate->setButton($url, t('Confirm My Email Address'));
} else {
$emailTemplate->setButton(externalUrl('/'), t('Access the Site'));
}
$emailTemplate->setMessage($message);
$emailTemplate->setTitle(t('Welcome Aboard!'));
$Email->setEmailTemplate($emailTemplate);
$Email->send();
}