Why is my DKIM key exceeding the character limit?

DomainKeys Identified Mail (DKIM) is an email authentication method designed to detect email spoofing. It allows the receiver to check that an email claimed to have come from a specific domain was indeed authorized by the owner of that domain. A common issue some administrators encounter is that their DKIM key is too long, especially when the DNS system typically limits the TXT record size.

DKIM keys are often generated at lengths of 1024 or 2048 bits. While a 1024-bit key is generally sufficient and more widely supported, some organizations opt for a 2048-bit key for added security. However, the longer the key, the longer the DKIM record, and this can sometimes exceed the character limits imposed by DNS providers (often 255 characters per string).

Split a DKIM Record:

A DKIM record that exceeds the DNS provider's character limit can lead to issues in implementing DKIM. If the record is truncated or improperly formatted, it can prevent email authentication, leading to emails being marked as spam or not being delivered at all.

Identify the Character Limit: First, you should determine the character limit for TXT records set by your DNS provider. If you're using Cloudflare, then you shouldn't have problems as they split the DNS record themselves. However, certain other DNS implementations offered by cPanel may have trouble with long DKIM keys.

Split the DKIM Key: If your DKIM key exceeds this limit, you will need to split it into multiple strings. This is typically done within the DNS record itself.

Formatting the Split Record:

Open your DKIM record. It will look something like this: "v=DKIM1; k=rsa; p=MIGfMA0GCSqGSIb3DQEBA..."

You need to split the p= part of the record into multiple strings. Each string should be enclosed in quotation marks and should not exceed your DNS provider's character limit.

Example: If your limit is 255 characters, you might split your DKIM key like this:

"v=DKIM1; k=rsa; p=MIGfMA0GCSqGSIb3DQEB"
"AQUAA4GNADCBiQKBgQDlZm..."
"rest_of_the_key..."

Updating DNS Record: Update your DNS record with these split strings, ensuring each part is properly quoted.

Test Your DKIM Record: After updating, it's crucial to test your DKIM record to ensure it's valid. You can use various online tools to validate your DKIM record.

If you're using cPanel, please follow this guide on the official cPanel Guide.


You can also use a third-party tool such as DNS Record Splitter offered by MailHardener.

For example, if your DKIM record is:

v=DKIM1;h=sha256;p=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEArcQusZKUwYJRGOFcD6uFi2jR1QiVi0BXWV+wTCBHBwi/IsYbVAaXOyxN9QG0R6UusHH5foZzt0GXkVfLzKM5qEG1A1ec/VGWcdN5fmPfAeAT/CifdSrS+7LLwaSV5sIvRpIv5I0R1My2PZd/1mxEkudJfnn4RzOe01cBqGeeePBRwQpyMkQaKc9zM5v/31OyjwQYvxq2EbtIbTt6XCizSKs7StxVZAuLKdI66CXnmBFxcMnYyKXcyvl+ICOyQkOS0vZQp6Iz7DCM2g5daKgqUYykSEoxGIeXtTNephFLwl/2jbXNvoqJVy4q4JHnX7WKtm/1DUH7zQZFhYCCyrkLXwIDAQAB

You can split into two smaller records such as:

v=DKIM1;h=sha256;p=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEArcQusZKUwYJRGOFcD6uFi2jR1QiVi0BXWV+wTCBHBwi/IsYbVAaXOyxN9QG0R6UusHH5foZzt0GXkVfLzKM5qEG1A1ec/VGWcdN5fmPfAeAT/CifdSrS+7LLwaSV5sIvRpIv5I0R1My2PZd/1mxEkudJfnn4RzOe01cBqGeeePBRwQpyMkQaKc9zM5v/31Oy
jwQYvxq2EbtIbTt6XCizSKs7StxVZAuLKdI66CXnmBFxcMnYyKXcyvl+ICOyQkOS0vZQp6Iz7DCM2g5daKgqUYykSEoxGIeXtTNephFLwl/2jbXNvoqJVy4q4JHnX7WKtm/1DUH7zQZFhYCCyrkLXwIDAQAB

The receiving email service providers will automatically merge these two records and consider them as one!