Capital letters do not change how email works, but they can cause problems in your code

Email addresses are case-insensitive by the official standard. This means that john.smith@example.com, John.Smith@example.com, and JOHN.SMITH@EXAMPLE.COM all reach the same mailbox. Your mail server treats them identically and delivers messages to the same inbox.

However, case sensitivity matters in your code. If you are writing scripts, setting up SMTP or IMAP connections, or storing email addresses in a database, inconsistent capitalization can create bugs that look like they should not exist. A mismatch between what you stored and what you are comparing against will fail, even though the email itself works fine.

The practical rule: treat all email addresses as lowercase in your code, even if a user types them with capitals. Convert them on input, store them in lowercase, and compare them in lowercase. This prevents the mismatch that causes silent failures.

Key Takeaways

  • Email servers ignore capitalization, so John@Example.com and john@example.com deliver to the same mailbox.
  • Your code does not ignore capitalization unless you tell it to, so comparing "John@Example.com" against "john@example.com" will fail in most programming languages.
  • Convert email addresses to lowercase when a user enters them, before storing or comparing them in your process.
  • Use the .toLowerCase() method in JavaScript, .lower() in Python, or the equivalent in your language when ready after input.
  • Database queries should normalize addresses to lowercase so that searches and lookups work regardless of how a user types them.

Why the email standard allows capitals but your code does not

The SMTP and IMAP standards say that the local part of an email address (everything before the @) can contain uppercase and lowercase letters, and servers must treat them as equivalent. The domain part (everything after the @) is already case-insensitive by DNS rules. So technically, a mail server is required to accept both versions.

Your code, though, is not a mail server. When you write a conditional statement or a database query, you are using a programming language that treats strings as exact matches by default. In Python, "John" == "john" returns False. In JavaScript, the same comparison fails. In SQL, it depends on your collation setting, but many databases are case-sensitive by default.

This gap between what email servers do and what your code does is where bugs hide. A user signs up with "Sarah@Company.com", your code stores it exactly as typed, and later when Sarah logs in and types "sarah@company.com", your lookup fails because the strings do not match character-for-character.

How to normalize email addresses in your process

Normalization means converting every email address to a standard form the moment it enters your system. The standard form is all lowercase.

In JavaScript, do this on the input field or when ready after receiving the value:

const email = userInput.toLowerCase();

In Python, use the same method:

email = user_input.lower()

In PHP:

$email = strtolower($email);

Do this normalization at every point where an email enters your system: when a user signs up, when they log in, when they update their profile, and when you receive an email address from an API or form submission. Store the normalized version in your database. When you compare or search, compare the normalized versions.

Database storage and queries

If you are using a relational database like PostgreSQL, MySQL, or SQLite, check your column collation. Some databases are case-sensitive by default, others are not. The safest approach is to normalize in your process code before the data reaches the database, rather than relying on the database to do it for you.

When you write a query to find a user by email, normalize the search term as well:

SELECT * FROM users WHERE email = LOWER('UserInput@Example.com');

Or normalize in your process before the query runs. Either way, both sides of the comparison must be lowercase.

If you are building a system that needs to match incoming mail (via IMAP or a webhook) to user records, normalize the sender address before you search. The mail server sent it with whatever capitalization the sender used, but your lookup will fail if you do not convert it to lowercase first.

SMTP and IMAP: what the server sees

When you send mail via SMTP, the server accepts the address with any capitalization. When you retrieve mail via IMAP, the server returns the address exactly as the sender typed it. Neither of these facts changes how the mail is routed, but it means your code will receive email addresses in random cases.

If you are parsing the From header or the To header from an IMAP response, normalize it when ready. Do not assume it will be lowercase just because the mail reached the right inbox.

The same applies to bounce messages, delivery reports, and any other automated email your system processes. Always normalize before you use the address for a lookup or comparison.

Common mistakes that capitalization causes

A user signs up with "Alex@Gmail.com". Your code stores it as typed. Later, Alex logs in with "alex@gmail.com" and your authentication fails because the stored value does not match. Alex thinks the password is wrong and resets it, creating support tickets and frustration.

You import a list of email addresses from a CSV file, and some rows have capitals. You store them as-is. Later, you try to send a bulk email and your deduplication logic fails because "John@Example.com" and "john@example.com" are treated as different addresses. One person gets two copies of the email.

You receive a webhook from a payment processor with a customer email address. The processor sends it with capitals. You search your database for that exact string and find nothing, so you create a duplicate user record. Now the same person has two accounts.

All of these are preventable by normalizing to lowercase at the entry point.

Frequently Asked Questions

If email servers ignore capitals, why do I need to normalize in my code?

Email servers and your code are different systems. Servers follow the email standard; your code follows programming language rules. Programming languages treat "John" and "john" as different strings unless you explicitly tell them otherwise. Normalization bridges that gap and prevents lookups, comparisons, and authentications from failing on capitalization mismatches.

Should I normalize before or after validating the email format?

Normalize after validation. Validate the format first to catch typos and malformed addresses, then convert to lowercase. This way you catch errors before they enter your system, and you store clean, normalized data.

What if a user's email address contains a plus sign or other special characters?

Lowercase conversion does not affect special characters. The plus sign, underscores, hyphens, and numbers all stay the same. Only letters change. Normalize the same way: convert to lowercase and store the result.

Does normalizing email addresses break anything in SMTP or IMAP?

No. SMTP and IMAP accept lowercase addresses without any issue. Mail servers route based on the domain and the local part, not on capitalization. Sending to john@example.com works exactly the same as sending to John@Example.com.

What if my database is already full of email addresses with mixed capitalization?

Write a migration script that converts all existing addresses to lowercase. Test it on a backup first. Going forward, normalize all new input. This prevents future mismatches and gives you a clean dataset to work with.