[Plugin: Postie] Multiple emailadresses per user
-
I have change the functiosn ValidatePoster and CheckEmailAddress in postie-functions.php so i can add more than 1 email per user using the Authorized Addresses box.
Example: add “email@hosting.com;Username” to Authorized Addresses box
The changed functions are below:
// completely changed function CheckEmailAddress($address, $authorized,&$user = '') { $isAuthorized = FALSE; $delimiter = ';'; foreach($authorized as $authorizedaddress) { if(strpos($authorizedaddress,$delimiter) === false) { if($authorizedaddress == $address) { $isAuthorized = TRUE; } } else { $arr = explode(';',$authorizedaddress); if($arr[0] === $address) { $user = $arr[1]; $isAuthorized = TRUE; } } } //$isAuthorized = in_array( strtolower($address), $authorized ); return $isAuthorized; }
and
function ValidatePoster( &$mimeDecodedEmail, $config ) { extract($config); global $wpdb; $poster = NULL; $from = RemoveExtraCharactersInEmailAddress(trim($mimeDecodedEmail->headers["from"])); $resentFrom = RemoveExtraCharactersInEmailAddress(trim($mimeDecodedEmail->headers["resent-from"])); /* if ( empty($from) ) { echo 'Invalid Sender - Emtpy! '; return; } */ //See if the email address is one of the special authorized ones print("Confirming Access For $from \n"); $sql = 'SELECT id FROM '. $wpdb->users.' WHERE user_email=\'' . addslashes($from) . "' LIMIT 1;"; $user_ID= $wpdb->get_var($sql); //CHANGE: add var $user_name and set it to the admin_username as default $user_name = $admin_username; if (!empty($user_ID)) { $user = new WP_User($user_ID); if ($user->has_cap("post_via_postie")) { $poster = $user_ID; echo "posting as user $poster"; } else { $poster = $wpdb->get_var("SELECT ID FROM $wpdb->users WHERE user_login = '$admin_username'"); } } elseif ($turn_authorization_off || CheckEmailAddress($from, $authorized_addresses,$user_name) || CheckEmailAddress($resentFrom, $authorized_addresses,$user_name)) { // die($user_name); //CHANGE: Set query to find the user_name + add user_name to the function CheckEmailAddress $poster = $wpdb->get_var("SELECT ID FROM $wpdb->users WHERE user_login = '$user_name'"); } $validSMTP=checkSMTP($mimeDecodedEmail, $smtp); if (!$poster || !$validSMTP) { echo 'Invalid sender: ' . htmlentities($from) . "! Not adding email!\n"; if ($forward_rejected_mail) { $admin_email = get_option("admin_email"); if (MailToRecipients($mimeDecodedEmail, $test_email, array($admin_email), $return_to_sender)) { echo "A copy of the message has been forwarded to the administrator.\n"; } else { echo "The message was unable to be forwarded to the adminstrator.\n"; } } return; } return $poster; }
- The topic ‘[Plugin: Postie] Multiple emailadresses per user’ is closed to new replies.