How to block mail for whole domain

To block mail for a whole domain, you can use various methods depending on your email provider or mail server configuration. Here are a few approaches:

Method 1: DNS-based blocking (SPF and DKIM)

  1. Set up a Sender Policy Framework (SPF) record for your domain. This record specifies which mail servers are authorized to send emails on behalf of your domain.
  2. Set up DomainKeys Identified Mail (DKIM) for your domain. This record authenticates the sender of an email by verifying a digital signature.
  3. Configure your mail server to include the SPF and DKIM records in the headers of outgoing emails.

Method 2: Mail server configuration (e.g., Postfix, Sendmail, Exim)

  1. Edit your mail server's configuration file (e.g., /etc/postfix/main.cf for Postfix).
  2. Add a rule to block emails from a specific domain. For example, you can add a smtpd_recipient_restrictions directive to block emails from example.com:
    smtpd_recipient_restrictions = check_recipient_access hash:/etc/postfix/recipient_access, reject_sender_login_mismatch, reject_non_fqdn_sender, reject_unknown_sender_domain, reject_rbl_client spamhaus.org, reject_rbl_client bl.spamcop.net, check_recipient_access pcre:/etc/postfix/recipient_access_pcre
  3. Create a new file (e.g., /etc/postfix/recipient_access) with the following contents:
    example.com REJECT
  4. Restart your mail server to apply the changes.

Method 3: Email client or webmail configuration

  1. If you're using an email client (e.g., Microsoft Outlook, Mozilla Thunderbird), you can set up a filter to block emails from a specific domain.
  2. If you're using a webmail service (e.g., Gmail, Yahoo Mail), you can set up a filter to block emails from a specific domain.

Example: Gmail filter

  1. Log in to your Gmail account.
  2. Click on the gear icon and select "See all settings."
  3. Go to the "Filters and Blocked Addresses" tab.
  4. Click on "Create a new filter."
  5. Enter the domain you want to block (e.g., example.com) in the "From" field.
  6. Select "Delete it" as the action.
  7. Click "Create" to save the filter.

Remember to test your blocking configuration to ensure it's working as expected.