本文整理汇总了PHP中Mail_RFC822::isValidInetAddress方法的典型用法代码示例。如果您正苦于以下问题:PHP Mail_RFC822::isValidInetAddress方法的具体用法?PHP Mail_RFC822::isValidInetAddress怎么用?PHP Mail_RFC822::isValidInetAddress使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mail_RFC822
的用法示例。
在下文中一共展示了Mail_RFC822::isValidInetAddress方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: send
/**
* Send an email message.
*
* @access public
* @param string $to Recipient email address
* @param string $from Sender email address
* @param string $subject Subject line for message
* @param string $body Message body
* @param string $replyTo Someone to reply to
*
* @return mixed PEAR error on error, boolean true otherwise
*/
public function send($to, $from, $subject, $body, $replyTo = null)
{
global $logger;
// Validate sender and recipient
$validator = new Mail_RFC822();
//Allow the to address to be split
$validator->_splitAddresses($to);
foreach ($validator->addresses as $tmpAddress) {
if (!$validator->isValidInetAddress($tmpAddress['address'])) {
return new PEAR_Error('Invalid Recipient Email Address ' . $tmpAddress);
}
}
if (!$validator->isValidInetAddress($from)) {
return new PEAR_Error('Invalid Sender Email Address');
}
$headers = array('To' => $to, 'Subject' => $subject, 'Date' => date('D, d M Y H:i:s O'), 'Content-Type' => 'text/plain; charset="UTF-8"');
if (isset($this->settings['fromAddress'])) {
$logger->log("Overriding From address, using " . $this->settings['fromAddress'], PEAR_LOG_INFO);
$headers['From'] = $this->settings['fromAddress'];
$headers['Reply-To'] = $from;
} else {
$headers['From'] = $from;
}
if ($replyTo != null) {
$headers['Reply-To'] = $replyTo;
}
// Get mail object
if ($this->settings['host'] != false) {
$mailFactory = new Mail();
$mail =& $mailFactory->factory('smtp', $this->settings);
if (PEAR_Singleton::isError($mail)) {
return $mail;
}
// Send message
return $mail->send($to, $headers, $body);
} else {
//Mail to false just emits the information to screen
$formattedMail = '';
foreach ($headers as $key => $header) {
$formattedMail .= $key . ': ' . $header . '<br />';
}
$formattedMail .= $body;
$logger->log("Sending e-mail", PEAR_LOG_INFO);
$logger->log("From = {$from}", PEAR_LOG_INFO);
$logger->log("To = {$to}", PEAR_LOG_INFO);
$logger->log($subject, PEAR_LOG_INFO);
$logger->log($formattedMail, PEAR_LOG_INFO);
return true;
}
}
示例2: send
/**
* Send an email message.
*
* @param string $to Recipient email address
* @param string $from Sender email address
* @param string $subject Subject line for message
* @param string $body Message body
*
* @return mixed PEAR error on error, boolean true otherwise
* @access public
*/
public function send($to, $from, $subject, $body)
{
// Validate sender and recipient
if (!Mail_RFC822::isValidInetAddress($to)) {
return new PEAR_Error('Invalid Recipient Email Address');
}
if (!Mail_RFC822::isValidInetAddress($from)) {
return new PEAR_Error('Invalid Sender Email Address');
}
// Change error handling behavior to avoid termination during mail
// process....
PEAR::setErrorHandling(PEAR_ERROR_RETURN);
// Get mail object
$mail =& Mail::factory('smtp', $this->settings);
if (PEAR::isError($mail)) {
return $mail;
}
// Send message
$headers = array('From' => $from, 'To' => $to, 'Subject' => $subject, 'Date' => date('D, d M Y H:i:s O'), 'Content-Type' => 'text/plain; charset="UTF-8"');
$result = $mail->send($to, $headers, $body);
return $result;
}
示例3: getMyProfile
/**
* Get Patron Profile
*
* This is responsible for retrieving the profile for a specific patron.
*
* @param array $patron The patron array
*
* @return mixed Array of the patron's profile data on success,
* PEAR_Error otherwise.
* @access public
*/
public function getMyProfile($patron)
{
$sql = "SELECT PATRON.LAST_NAME, PATRON.FIRST_NAME, " . "PATRON.HISTORICAL_CHARGES, PATRON_ADDRESS.ADDRESS_LINE1, " . "PATRON_ADDRESS.ADDRESS_LINE2, PATRON_ADDRESS.ZIP_POSTAL, " . "PATRON_ADDRESS.CITY, PATRON_ADDRESS.COUNTRY, " . "PATRON_PHONE.PHONE_NUMBER, PATRON_GROUP.PATRON_GROUP_NAME " . "FROM {$this->dbName}.PATRON, {$this->dbName}.PATRON_ADDRESS, " . "{$this->dbName}.PATRON_PHONE, {$this->dbName}.PATRON_BARCODE, " . "{$this->dbName}.PATRON_GROUP " . "WHERE PATRON.PATRON_ID = PATRON_ADDRESS.PATRON_ID (+) " . "AND PATRON_ADDRESS.ADDRESS_ID = PATRON_PHONE.ADDRESS_ID (+) " . "AND PATRON.PATRON_ID = PATRON_BARCODE.PATRON_ID (+) " . "AND PATRON_BARCODE.PATRON_GROUP_ID = " . "PATRON_GROUP.PATRON_GROUP_ID (+) " . "AND PATRON.PATRON_ID = :id";
try {
$sqlStmt = $this->db->prepare($sql);
$this->debugLogSQL(__FUNCTION__, $sql, array(':id' => $patron['id']));
$sqlStmt->execute(array(':id' => $patron['id']));
$patron = array();
while ($row = $sqlStmt->fetch(PDO::FETCH_ASSOC)) {
if (!empty($row['FIRST_NAME'])) {
$patron['firstname'] = utf8_encode($row['FIRST_NAME']);
}
if (!empty($row['LAST_NAME'])) {
$patron['lastname'] = utf8_encode($row['LAST_NAME']);
}
if (!empty($row['PHONE_NUMBER'])) {
$patron['phone'] = utf8_encode($row['PHONE_NUMBER']);
}
if (!empty($row['PATRON_GROUP_NAME'])) {
$patron['group'] = utf8_encode($row['PATRON_GROUP_NAME']);
}
include_once 'Mail/RFC822.php';
$addr1 = utf8_encode($row['ADDRESS_LINE1']);
if (Mail_RFC822::isValidInetAddress($addr1)) {
$patron['email'] = $addr1;
} else {
if (!isset($patron['address1'])) {
if (!empty($addr1)) {
$patron['address1'] = $addr1;
}
if (!empty($row['ADDRESS_LINE2'])) {
$patron['address2'] = utf8_encode($row['ADDRESS_LINE2']);
}
$patron['zip'] = !empty($row['ZIP_POSTAL']) ? utf8_encode($row['ZIP_POSTAL']) : '';
if (!empty($row['CITY'])) {
if ($patron['zip']) {
$patron['zip'] .= ' ';
}
$patron['zip'] .= utf8_encode($row['CITY']);
}
if (!empty($row['COUNTRY'])) {
if ($patron['zip']) {
$patron['zip'] .= ', ';
}
$patron['zip'] .= utf8_encode($row['COUNTRY']);
}
}
}
}
return empty($patron) ? null : $patron;
} catch (PDOException $e) {
return new PEAR_Error($e->getMessage());
}
}
示例4: explode
print "</form>\n</body>\n</html>\n";
exit;
}
//
// Verify email adresses
include_once 'Mail/RFC822.php';
$email_var = get_form_var('Field_email', 'string');
if (!isset($email_var)) {
$email_var = '';
}
$emails = explode(',', $email_var);
$valid_email = new Mail_RFC822();
foreach ($emails as $email) {
// if no email address is entered, this is OK, even if isValidInetAddress
// does not return TRUE
if (!$valid_email->isValidInetAddress($email, $strict = FALSE) && '' != $email_var) {
// Now display this form again with an error message
Header("Location: edit_users.php?Action=Edit&Id={$Id}&invalid_email=1");
exit;
}
}
//
if ($Id >= 0) {
$operation = "replace into {$tbl_users} values (";
} else {
$operation = "insert into {$tbl_users} values (";
$Id = sql_query1("select max(id) from {$tbl_users};") + 1;
/* Use the last index + 1 */
/* Note: If the table is empty, sql_query1 returns -1. So use index 0. */
}
$i = 0;
示例5: basename
print get_vocab("passwords_not_eq") . "<br>\n";
print "<form method=post action=\"" . basename($PHP_SELF) . "\">\n";
print " <input type=submit value=\" " . get_vocab("ok") . " \" /> <br />\n";
print "</form>\n</body>\n</html>\n";
exit;
}
//
// Verify email adresses
include_once 'Mail/RFC822.php';
!isset($Field[3]) ? $Field[3] = '' : '';
$emails = explode(',', $Field[3]);
$valid_email = new Mail_RFC822();
foreach ($emails as $email) {
// if no email address is entered, this is OK, even if isValidInetAddress
// does not return TRUE
if (!$valid_email->isValidInetAddress($email, $strict = FALSE) && '' != $Field[3]) {
// Now display this form again with an error message
Header("Location: edit_users.php?Action=Edit&Id={$Id}&invalid_email=1");
exit;
}
}
//
if ($Id >= 0) {
$operation = "replace into {$tbl_users} values (";
} else {
$operation = "insert into {$tbl_users} values (";
$Id = sql_query1("select max(id) from {$tbl_users};") + 1;
/* Use the last index + 1 */
/* Note: If the table is empty, sql_query1 returns -1. So use index 0. */
}
for ($i = 0; $i < $nfields; $i++) {
示例6: explode
<?php
}
?>
<?php
if (!empty($area)) {
include_once 'Mail/RFC822.php';
!isset($area_admin_email) ? $area_admin_email = '' : '';
$emails = explode(',', $area_admin_email);
$valid_email = TRUE;
$email_validator = new Mail_RFC822();
foreach ($emails as $email) {
// if no email address is entered, this is OK, even if isValidInetAddress
// does not return TRUE
if (!$email_validator->isValidInetAddress($email, $strict = FALSE) && '' != $area_admin_email) {
$valid_email = FALSE;
}
}
//
if (isset($change_area) && FALSE != $valid_email) {
$sql = "UPDATE {$tbl_area} SET area_name='" . addslashes($area_name) . "', area_admin_email='" . addslashes($area_admin_email) . "' WHERE id={$area}";
if (sql_command($sql) < 0) {
fatal_error(0, get_vocab("update_area_failed") . sql_error());
}
}
$res = sql_query("SELECT * FROM {$tbl_area} WHERE id={$area}");
if (!$res) {
fatal_error(0, get_vocab("error_area") . $area . get_vocab("not_found"));
}
$row = sql_row_keyed($res, 0);
示例7: COM_isEmail
/**
* Checks to see if email address is valid.
*
* This function checks to see if an email address is in the correct from.
*
* @param string $email Email address to verify
* @return boolean True if valid otherwise false
*
*/
function COM_isEmail($email)
{
require_once 'Mail/RFC822.php';
$rfc822 = new Mail_RFC822();
return $rfc822->isValidInetAddress($email) ? true : false;
}
示例8: _processInput
/**
* Process incoming parameters for account creation.
*
* @return mixed True on successful account creation, PEAR_Error otherwise.
* @access private
*/
private function _processInput()
{
// Validate Input
if (trim($_POST['username']) == '') {
return new PEAR_Error('Username cannot be blank');
}
if (trim($_POST['password']) == '') {
return new PEAR_Error('Password cannot be blank');
}
if ($_POST['password'] != $_POST['password2']) {
return new PEAR_Error('Passwords do not match');
}
if (!Mail_RFC822::isValidInetAddress($_POST['email'])) {
return new PEAR_Error('Email address is invalid');
}
// Create Account
$user = new User();
$user->username = $_POST['username'];
if (!$user->find()) {
// No username match found -- check for duplicate email:
$user = new User();
$user->email = $_POST['email'];
if (!$user->find()) {
// We need to reassign the username since we cleared it out when
// we did the search for duplicate email addresses:
$user->username = $_POST['username'];
$user->password = $_POST['password'];
$user->firstname = $_POST['firstname'];
$user->lastname = $_POST['lastname'];
$user->created = date('Y-m-d h:i:s');
$user->insert();
} else {
return new PEAR_Error('That email address is already used');
}
} else {
return new PEAR_Error('That username is already taken');
}
return true;
}
示例9: send
/**
* Send an email message.
*
* @param string $to Recipient email address
* @param string $from Sender email address
* @param string $subject Subject line for message
* @param string $body Message body
*
* @return mixed PEAR error on error, boolean true otherwise
* @access public
*/
public function send($to, $from, $subject, $body)
{
// Validate sender and recipient
foreach (explode(',', $to) as $address) {
if (!Mail_RFC822::isValidInetAddress($address)) {
return new PEAR_Error('Invalid Recipient Email Address');
}
}
if (!Mail_RFC822::isValidInetAddress($from)) {
return new PEAR_Error('Invalid Sender Email Address');
}
// Change error handling behavior to avoid termination during mail
// process....
PEAR::setErrorHandling(PEAR_ERROR_RETURN);
// Get mail object
$mail =& Mail::factory('smtp', $this->settings);
if (PEAR::isError($mail)) {
return $mail;
}
$body = $this->getFlowedBody($body);
// Send message
$headers = array('From' => $this->mimeEncodeAddress($from), 'To' => $this->mimeEncodeAddress($to), 'Subject' => $this->mimeEncodeHeaderValue($subject), 'Date' => date('D, d M Y H:i:s O'), 'Content-Type' => 'text/plain; charset="UTF-8"; format=flowed', 'Content-Transfer-Encoding' => '8bit', 'X-Mailer' => 'VuFind');
$result = $mail->send($to, $headers, $body);
return $result;
}
示例10: launch
//.........这里部分代码省略.........
$data['dueDateAlert'] = $txt;
}
}
$result = $this->sendEmail($patron, $data, 'Viestiasetusten muutospyyntö', 'Emails/change-messaging-settings.tpl');
if (!PEAR::isError($result)) {
$userMessages[] = 'request_change_email_sent';
} else {
error_log('Sending of messaging settings change request mail failed: ' . $result->getMessage());
$userErrors[] = 'request_change_email_failed';
}
}
// Change home library
if (isset($_POST['home_library']) && $_POST['home_library'] != "") {
$home_library = $_POST['home_library'];
if ($user->changeHomeLibrary($home_library)) {
$userMessages[] = 'profile_update';
} else {
$userErrors[] = 'profile_update_failed';
}
}
// Change Password
if (isset($_POST['oldPassword']) && isset($_POST['newPassword']) && isset($_POST['newPassword2'])) {
if ($_POST['newPassword'] !== $_POST['newPassword2']) {
$userErrors[] = 'change_password_error_verification';
} else {
$result = $this->changePassword($_POST['oldPassword'], $_POST['newPassword']);
if (PEAR::isError($result)) {
$userErrors[] = $result->getMessage();
} else {
if ($result['success']) {
$userMessages[] = 'change_password_ok';
$user->changeCatalogPassword($_POST['newPassword']);
// Re-retrieve patron to make sure it's up to date
$patron = UserAccount::catalogLogin();
} else {
$userErrors[] = $result['status'];
}
}
}
}
// Change phone number
if (isset($_POST['phone_number'])) {
$phoneNumber = trim($_POST['phone_number']);
if (preg_match('/^[\\+]?[ \\d\\-]+\\d+$/', $phoneNumber)) {
$result = $this->catalog->setPhoneNumber($patron, $phoneNumber);
if ($result['success']) {
$userMessages[] = 'phone_updated';
// Re-retrieve patron to make sure it's up to date
$patron = UserAccount::catalogLogin();
} else {
$userErrors[] = $result['sys_message'];
}
} else {
$userErrors[] = 'Phone Number is invalid';
}
}
// Change email address
if (isset($_POST['email_address'])) {
$email = trim($_POST['email_address']);
if (Mail_RFC822::isValidInetAddress($email)) {
$result = $this->catalog->setEmailAddress($patron, $email);
if ($result['success']) {
$userMessages[] = 'email_updated';
// Re-retrieve patron to make sure it's up to date
$patron = UserAccount::catalogLogin();
} else {
$userErrors[] = $result['sys_message'];
}
} else {
$userErrors[] = 'Email address is invalid';
}
}
$result = $this->catalog->getMyProfile($patron);
if (!PEAR::isError($result)) {
$result['home_library'] = $user->home_library;
$libs = $this->catalog->getPickUpLocations($patron);
$defaultPickUpLocation = $this->catalog->getDefaultPickUpLocation($patron);
$interface->assign('defaultPickUpLocation', $defaultPickUpLocation);
$interface->assign('pickup', $libs);
$interface->assign('profile', $result);
} else {
$userErrors[] = $result->getMessage();
}
$result = $this->catalog->checkFunction('changePassword');
if ($result !== false) {
$interface->assign('changePassword', $result);
}
$driver = isset($patron['driver']) ? $patron['driver'] : '';
$interface->assign('driver', $driver);
}
}
$interface->assign('userMsg', array_unique($userMessages));
$interface->assign('userError', array_unique($userErrors));
$interface->assign('hideDueDateReminder', isset($configArray['Site']['hideDueDateReminder']) && (bool) $configArray['Site']['hideDueDateReminder']);
$interface->assign('hideProfileEmailAddress', isset($configArray['Site']['hideProfileEmailAddress']) && (bool) $configArray['Site']['hideProfileEmailAddress']);
Login::setupLoginFormVars();
$interface->setTemplate('profile.tpl');
$interface->setPageTitle('My Profile');
$interface->display('layout.tpl');
}