Set up rules for attachment compliance

As a G Suite administrator, you can set up compliance rules for message attachments, such as documents, video and sound files, images, and compressed files and archives. Rules specify conditions based on file type, file name, and message size. They also specify how to handle messages that meet the conditions.

Compliance actions

The following actions can be taken on a message that contains an attachment:    

  • Reject the message
  • Quarantine the message and attachment for review
  • Modify the delivery of the message and the attachment  

You can also set up a rule to detect encrypted attachments. This distinction can be useful if you need to send unencrypted copies of message attachments to an archive server for regulatory purposes.

How attachments are scanned

Gmail supports binary file-type detection for pre-defined and custom file types, which helps prevent people from circumventing attachment rules by renaming extensions. Files are scanned based file type, for example doc. Gmail scans the filenames of files inside archives, including encrypted archives and nested non-encrypted archives. However, the inner archives of an encrypted archive cannot be scanned.

Gmail cannot open or inspect attachments that are password-protected files or archives. This includes ZIP files that are password protected. G Suite can inspect ZIP file attachments if they are not password protected.

How settings are applied

Unless you change the options, the rules apply to all users in an organizational unit. You can disable in a child organization any rules they inherit from a parent organization.. You can also add multiple rules to each organization.

When you set up multiple rules, what happens to a message depends on the conditions you set and which rule has precedence. For details, see How multiple settings affect message behavior.

Enhance message security with hosted S/MIME

You can improve message security with S/MIME. For example, set up a rule that requires S/MIME encryption for outgoing messages. Set this rule up with the Encryption option, described in step 4 above.

For an overview, see Enhance message security with hosted S/MIME.

This feature is only available with G Suite Enterprise and G Suite Enterprise for Education.

Set up an attachment compliance rule

Initial step: Go to Gmail advanced settings in the Google Admin console

  1. Sign in to your Google Admin console.

    Sign in using your administrator account (does not end in @gmail.com).

  2. From the Admin console Home page, go to Appsand thenG Suiteand thenGmailand thenAdvanced settings.

    Tip: To see Advanced settings, scroll to the bottom of the Gmail page.

  3. Scroll to the Attachment compliance setting in the Compliance section, hover over the setting, and click Configure. If the setting is already configured, hover over the setting and click Edit or Add another.

  4. For each new setting, enter a unique description.

Go to the next step to configure the setting.

Step 1: Enter email messages to affect

You can set up the rule for inbound, outbound, or internal messages. Internal messages are sent and received within the domains and subdomains associated with your organization.
  1. Check the boxes next to the messages you want the rule to apply to.

  2. Go to the next step to continue.

Step 2: Add one or more expressions to specify what's searched

You can add up to 10 expressions. Each expression must individually added and saved. 

  1. From the list, specify whether any or all conditions must match to trigger what happens to the message. For example, if you select If ANY of the following match the message, any matching condition can trigger the consequence to the message.

  2. Click Add.

  3. From the list, choose what you want to specify for the expression:

    • File type—Select the attachment types to include. You can also enter a custom file type to look for matches based on that file type.

      Note: For your protection, file types that are considered to be executables are automatically rejected. To see a complete list of extensions, see File types and extensions supported in expressions.

    • File name—Enter an attachment name that you want to include. Any part of an attachment file name is returned as a match, whether it's upper or lowercase.

    • Message size—Enter, in megabytes, the size limit for messages. The size includes the message body and all attachments. (This is the raw size of the entire message, which may be up to 33% larger than the native size of the message and attachments due to normal encoding overhead.)

  4. Click Save. You might need to scroll to see it.

  5. Go to the next step to continue.

Step 3: Specify what happens if expressions match

  1. Specify whether to modify, reject, or quarantine a message when conditions are met. (Details below.)

  2. Configure the options for the actions you choose.

  3. (Optional) Click Show options to configure additional options to limit the application of this setting. See Configure additional parameters, below, for details.

  4. Go to Save the configuration.

 

Reject message

Rejects the message before reaching the recipient. You can enter a message to notify the sender about why the message was rejected. For matching messages, no other routing or compliance rules are applied. 

Note: Gmail automatically adds an SMTP rejection code, such as 550 5.7.1. This is a requirement of the SMTP standard and can't be deleted.

Quarantine message

Sends the message to an admin quarantine where you can review the message before you send or reject it. This option is only available for the Users account type. For details, see Account types to affect.

To notify your users when their sent messages are quarantined, check the Notify sender when mail is quarantined (onward delivery only) box.

Modify message

Add headers, remove attachments, change the envelope recipient, add more recipients, and change the route. For details, see Options for modifying messages.

Note: We recommend that you use the routing settings for the specific use cases they are intended to support. For example, you can set up the same routing options by using an Attachment compliance setting or a Routing setting. Use an Attachment compliance setting for attachment-related use cases, and a Routing setting for general routing-related use cases, such as dual delivery. Learn about mail routing, including use cases and examples.

Controls

Add X-Gm-Original-To header

Add a header tag if the recipient is changed. When you do, the downstream server will know the original envelope recipient. An example of the header tag format is X-Gm-Original-To: user@solarmora.com.

Add X-Gm-Spam and X-GM-Phishy headers

Add headers to indicate the spam and phishing status of the message. For example, an administrator at a downstream server can use this information to set up rules that handle spam and phishing differently from clean mail. For details, see Add spam headers setting to all default routing rules.

Add custom headers

You can add custom headers to messages that are affected by this setting. For example, you can add a header that matches the description that you entered for the setting. This can help you analyze why a message was routed in a certain way or why a rule was triggered.

Prepend custom subject

You can enter a string to add to the beginning of the subject of applicable messages. For example, you could enter Confidential in this field for sensitive emails. If a message triggers the rule and its subject is Monthly report, recipients will see the following subject: [Confidential] Monthly report.

Change route and Also reroute spam

  • Change route—You can change the destination of the message from the default Gmail server to a different mail server, such as Microsoft® Exchange.

    Note: Before you can change the route, you need to add the new route in the Admin console. For details, see Add mail routes for advanced Gmail delivery.

  • Also reroute spam—This option is available if you select Change route. Blatant spam is dropped instantly at delivery time. However, check the Also reroute spam box to route any additional email you mark as spam.

    Leaving the box unchecked has normal messages rerouted, but not spam. G Suite email settings (for example, a list of preauthorized senders) overrides spam settings.

Change envelope recipient

The message bypasses the original recipient’s mailbox and goes to the new recipient.

You can change the envelope recipient in one of the following ways:

  • Replace the recipient’s entire email address—After Replace recipient, enter the full email address, such as user@solarmora.com.
  • Replace the username—To change just the username of the recipient's email address and keep the domain the same, before @existing-domain, enter the username, such as user.
  • Replace the domain—To change just the domain of the recipient's email address and keep the username the same, after existing-username@, enter the domain, such as solarmora.com.

An MX lookup on the new recipient's domain determines the destination server. Or, if you’re using the Change route control, the specified route determines the destination server.

If you'd rather Bcc an additional recipient, use the Add more recipients option, described below.

Bypass spam filter for this message

Deliver incoming messages to recipients even if the spam filter identifies them as spam. This option applies to only incoming messages only. You can’t bypass spam filters for outgoing messages.

Note: This option is not available for the Groups account type. For details, see Account types to affect.

Remove attachments from message

You can remove any attachments from messages. You can also append text to notify recipients that attachments were removed.

Add more recipients

  1. To set up dual or multiple delivery, check the Add more recipients boxand thenclick Add .
  2. To add individual email addresses, select Basic from the listand thenclick Save
  3. (Optional) To add more addresses, click Add .
  4. (Optional) To choose advanced options for your secondary delivery, select Advanced from the list.

    You can change the envelope recipient, add headers, prepend a custom subject, and remove attachments for secondary deliveries.

When you add recipients, consider that:

  • Each rule has a limit of 100 additional recipients.
  • Settings for the primary delivery also apply to the secondary deliveries.
  • For secondary deliveries, the Do not deliver spam to this recipient and Suppress bounces from this recipient boxes are checked by default.
  • Adding additional recipients creates a message for each added recipient. Advanced Gmail settings apply to each message.

Encryption (onward delivery only)

By default, Gmail tries to deliver messages using Transport Layer Security (TLS). If secure transport isn’t available, the message is delivered over a nonsecure connection.

To require all messages meeting the conditions in the setting to be transmitted through a secure connection, check the Require secure transport (TLS) box. If TLS isn't available on the sending or receiving side, the message won't be sent.

If you have a G Suite Enterprise or Enterprise for Education account, you can also bounce messages or require that messages can only be sent if they are S/MIME encrypted. For details, go to Enhance message security with hosted S/MIME.

  This feature is only available with G Suite Enterprise and G Suite Enterprise for Education.

Tip: We recommend that you test new rules to make sure they work correctly for your organization. For more information, see Best practices for faster rules testing.

Configure additional parameters (Optional)

To set up additional options for a routing policy, such as creating address lists or choosing the account types it will affect, at the bottom, click Show options.

Address lists

You can specify address lists as a criteria for whether to bypass or apply a given setting. Address lists can contain email addresses, domains, or both.

There are two methods used to determine if the address list is matched. If multiple lists are specified, the address must match at least one of the lists:

  • Correspondent (default) G Suite considers the "from" field for received mail and the recipients for sent mail. For senders, the authentication requirement is also checked. (Details below.).
  • Recipient: G Suite always checks to see if the recipients are present in address lists.

The options for whether to bypass or apply a given setting are:

  • Bypass this setting for specific addresses / domains—Skips the setting entirely if the address list matches, regardless of any other criteria specified in the setting.
  • Only apply this setting for specific addresses / domains—The address list match becomes a condition for whether the setting is applied. If there are other criteria in the setting, such as match expressions, account types, or envelope filters, those conditions must also match for the setting to be applied.

To use address lists to control application of this setting:

  1. In the Options section, check the Use address lists to bypass or control application of this setting box.
  2. Select one of the options:

    • Bypass this setting for specific addresses / domains
    • Only apply this setting for specific addresses / domains
  3. Click Use existing or create a new one.
  4. Select the name of an existing list, or, to create a new one, enter a custom name for a new list in the Create new list field, and then click Create.
  5. Move the pointer over the list name, and click Edit.

  6. To add email addresses or domains to the list, click Add .

  7. Enter a full email address or domain name, such as solarmora.com. Or, to add a list in bulk, enter a comma or space delimited list of addresses after clicking Add .

    Note: If you want to bypass this setting for approved senders that don't have authentication, uncheck the Require sender authentication box. Use this option with caution as it can potentially lead to spoofing. Learn more about sender authentication.

  8. Click Save.

  9. To include additional email addresses or domains in the list, repeat steps 5 to 7.

  10. When you're done, go to Account types to affect.

Learn more about address lists, including how to search, or view all entries in the list, and how addresses are matched against the address lists.

Account types to affect (Required)

Depending on the message action you chose and the type of organizational unit you’re configuring, some account types might not be available.

Select one or more account types that the setting applies to: 

  • Users (default)—The setting applies to provisioned G Suite users. For sending and outbound mail, the setting is triggered when your users send email. For receiving and inbound mail, the setting is triggered when your users receive email.
  • Groups—The setting applies to groups set up in your organization. For sending and outbound mail, the setting is triggered when your groups forward email or summaries to members. For receiving and inbound mail, the setting is triggered when your groups receive email.
  • Unrecognized/Catch-all—The setting is triggered when your organization receives email that doesn’t match one of your provisioned G Suite users. This selection only applies to received and inbound email.

Note: The Groups and Unrecognized/Catch-all account types don’t apply to these controls:

  • Add X-Gm-Spam and X-Gm-Phishy headers
  • Bypass spam filter for this message
  • Also reroute spam

When you're finished, go to Add and save the setting.

Envelope filter

You can choose to affect only specific envelope senders and recipients. You can specify a single recipient, a number of users using a regular expression, or email groups.

To set up an envelope filter:

  1. Check one or both of these options:
    • Only affect specific envelope senders
    • Only affect specific envelope recipients
  2. From the list, choose an option:
    • Single email address—Enter the complete email address for a user.
    • Pattern match—Enter a regular expression to specify a set of senders or recipients in your domain. For example:

      ^(?i)(user1@solarmora\.com|user2@solarmora\.com|user3@solarmora\.com)$

      For details, go to Guidelines for using regular expressions.

    • Group membership—Select one or more groups in the list. For envelope senders, this option only applies to sent mail. For envelope recipients, it only applies to received mail. If you haven't, first create the group.

When you're finished, go to Save the configuration.

Save the configuration

Final step: Add and save the setting

  1. Click Add setting or Save.

    New settings appear on the Gmail Advanced settings page.

  2. At the bottom, click Save.

Common and custom file types supported in expressions 

The table below defines common and custom file types you can use in an attachment compliance expression. For your protection, file types that are considered executables are automatically rejected. Learn more about blocked file types.

  • Common file types. By default, all common file types are matched by file format and filename to identify the type of content and the attachment's extension. Examples include image/photo.jpg or document/letter.doc.  
  • Custom file types. By default, custom file types are matched only by filename, for example, photo.jpg or letter.doc. To match custom file types to file format as well, check the Also match files based on file format box. 
Documents

.cpr, .cwk, .cws, .dcx, .doc, .docm, .docx, .dot, .dotm, .dotx, .fax, .fp, .fp3, .frm, .gim, .gix, .gna, .gnx, .gra, .mcw, .mdb, .mdn, .met, .mpp, .obd, .odg, .odp, .ods, .odt, .pdf, .potm, .potx, .ppam, .pps, .ppsm, .ppsx, .ppt, .pptm, .pptx, .pre, .prs, .rtf, .shb, .shw, .sldx, .sldm, .wb1, .wb2, .wdb, .wk1, .wk3, .wk4, .wks, .wp, .wpw, .wp4, .wp5, .wp6, .wpd, .wps, .wpt, .wq1, .wq2, .wri, .ws1, .ws2, .ws3, .ws4, .ws5, .ws6, .ws7, .wsd, .xlam, .xlm, .xls, .xlsb, .xlsm, .xlsx, .xlt, .xltm, .xltx

Images

.ai, .art, .att, .bmp, .cal, .cdr, .cdt, .cdx, .cmf, .cmp, .dib, .drw, .emf, .eps, .fh3, .fif, .fpx, .gem, .gif, .html, .icb, .iff, .ima, .img, .jbf, .jff, .jif, .jpeg, .jpg, .jtf, .kdc, .kfx, .lbm, .mac, .mic, .pbm, .pcd, .pcs, .pct, .pcx, .pgm, .pic, .pif, .png, .pnt, .ppm, .ps, .psd, .ras, .raw, .sct, .sdr, .sdt, .sep, .shg, .tga, .tif, .tiff, .vda, .vst, .wil, .wmf, .wpg, .wvl

Audio (music & sound)

.aif, .aiff, .ams, asf, .cda, .dcr, .dsm, .idd, .it, .mdl, .med, .mid, .mp3, .mtm, .mod, .mus, .nsa, .ra, .ram, .rm, .rmi, .rtm, .snd, .stm, .svx, .s3m, .ult, .voc, .wav, .wow

Video & multimedia

.avi, .cfb, .cmv, .dir, .gal, .m3d, .mmm, .mov, .mpe, .mpeg, .mvb, .qt, .qtm, .xtp, .xy3, .xy4, .xyp, .xyw, .mpg, .wmv

Compressed and archive file formats

.7z, .ace, .bz, .bz2, .cab, .gz, .hex, .hqx, .lzh, .pages, .rar, .sea, .sit, .tar, .tgz, .uue, .zip, .zoo

Custom types

asc., .brf, .c, .c++, .cc, .cpp, .css, .csv, .cxx, .eps2, .eps3, .epsf, .epsi, .epub, .es, .fnt, .fon, .h, .h++, .hh, .hpp, .hwp, .hxx, .jpe, .js, .kml, .kmz, .markdown, .md, .mdown, .mhtml, .mkd, .mkdn, .numbers, .otf, .otp, .ott, .php, .pht, .phtml, .pot, .qjs, .qjsp, .sdc, .sdd, .sdw, .shtm, .shtml, .svg, .svgz, .swf, .swfl, .sxc, .sxd, .sxi, .sxw, .tsv, .ttf, .wml, .xhtml, .xlb, .xml, .xps, .xsd, .xsl

Note: Although you can enter unsupported custom file types, they are matched only by filename, for example, document.sac

Was this helpful?
How can we improve it?