strpos
will return 0
for a positive match at the start of a string, so your condition != false
will evaluate as false
– in other words…
$email_domain = 'b-mail.online';
if ( strpos( $email_domain, 'b-mail.online' ) != false ) {
// Will never reach here
}
…this is because !=
is known as a loose comparison, and 0 == false
. You could use a strict comparison e.g. !== false
but in this case you don’t even need strpos
since you’re checking fully-qualified domain names. Just do something like:
$blocked_domains = [
'b-mail.online',
// Other domain names
];
if ( in_array( $email_domain, $blocked_domains, true ) ) {
$errors->add( 'email_error', '<strong>ERROR</strong>: Domain not allowed.' );
}
Related Posts:
- Emails not getting delivered to Hotmail addresses
- WordPress site member verification emails going to spam on Outlook
- Fighting Spam – What can I do as an: Email Administrator, Domain Owner, or User?
- How to send emails and avoid them being classified as spam?
- Sending multipart (text/html) emails via wp_mail() will likely get your domain banned
- How to set SMTP programmatically
- changing notification emails from WordPress @mydomain.net to something else
- Alert Email when any Post or Page is Changed
- Missing URL in password reset email
- prevent users from changing their email address
- Allow Duplicate Email Address for Different Users
- Include HTML template file in wp_mail
- Email sent from WordPress has HTML tags
- How to disable automated E-Mail on PHP error/exception?
- Reset Password – change from name and email address
- Send mail to wordpress admin
- WP Cron emails not working
- Few chars getting replaced with ‘=’ in mail content in wp_mail()
- Change Password notification text on mail
- On form submission how to send 2 email to different users
- Handle registrations in WordPress when user doesn’t have any email?
- Joining confirmation email
- How to setup SMTP for only one specific wp_mail()
- Sanitizing and validating email field
- Batch Emails with wp_mail()
- Email notification after registration in WordPress
- Subscribe from another website to the same list [closed]
- Email ‘from address’ has a www in it
- WordPress E-mail Config
- Is there no way to send email using SMTP without plugin or custom coding?
- Send email daily from WordPress site
- Is it possible to change an existing post status from ‘pending’ to ‘publish’ via email?
- WordPress email reply back to the original post author
- What can be wrong when automated backups stop being sent to email?
- Wp_new_user_notification doesn’t work
- Make WordPress use timezone for email Date header
- How to send mail from WordPress if one server hosts page and another email?
- WordPress unable to send mail
- Disable email confirmation new register bbPress [closed]
- Not able to send links in email after setting header
- Stop the execution of foreach loop which extract data from array?
- wp_mail_from is ignored
- How to receive an email with WordPress?
- How to edit the WordPress e-mail that gives the user their password? [duplicate]
- What is the best way to send out thousands of emails from a WordPress site? [closed]
- Do action for only switch status for publish_post
- Generate Email if No Posts Within Time Period
- Interrupted cron script sending me hourly emails. Please help!
- Content of post does not end up in “ShareThis” mail
- Programming WordPress to Send an Email on Registration Form Submit?
- Does WordPress require port 25 for email?
- How to differentiate between email subscription list and blog subscription list?
- Is there a plugin that will let you do actions by mail? [closed]
- What emails does wordpress send?
- Requiring wp-login.php sends headers automatically
- How to stop WordPress from sending mails?
- Changing email “From” address
- Changed my email. Locked out
- Add “Email Image” button with Hyperlink for individual images [closed]
- Send confirmation email when a user’s role is upgraded
- Mail through Cron Execution does not work!
- Sending a password reset link
- How to prevent sending auto emails for specific actions in wordpress
- Receive no any emails from contact from 7 wordpress
- Need to suspend RSS feed while repairing missing old post
- How to recover one of WP email addresses?
- WordPress emails are not delivered if the recipient email address has a non-traditional domain extension
- Is it possible to use different from email in contact form 7 with different domain?
- Activation email to change admin address not being sent to Gsuite email account
- Send email with Content-Type text/plain
- How can I remove the product short description from the WooCommerce Mails?
- forgot password page with expiry link email of 60 minutes
- I need to verify emails when users signup
- How to integerate WordPress Mail SMTP plugin to Report and Request custom page
- Where is the account email address located?
- wp_mail() not sending emails with ajax
- SMTP not working for Comments Email Notifications
- wordpress wp mail not changing sender mail
- changing notification emails from WordPress @mydomain.net to something else
- Emails sent from local wp webserver are beeing rejected from Siren?
- Send Bulk Email without them going to spam
- How can I send an email 24 hours after first email?
- email explanation for newbies
- WordPress doesn’t send SMTP email even by phpmailer hook
- Asynchronous emailing
- WordPress stops executing code after the require() method
- User Registration – no Email required
- Download Free Trial After Email Entered
- Duplicate notifications for new user registration
- Email notification
- Custom notification for contributors when posts are scheduled
- Allowing Loading/Downloading of .mp3
- Create WP account from an external email form submission?
- Contact Form 7 – E-mail message template [closed]
- Can wordpress users check GMAIL (G Suite) inbox & send email from their membership account on WordPress? [closed]
- How can I prevent wordpress from sending emails
- Welcome Email Going to Spam
- Choose from different emails for different purposes
- WordPress wp_mail not working on a few pages
- Admin email value stuck in database?