{"id":5896,"date":"2020-11-16T09:58:00","date_gmt":"2020-11-16T04:28:00","guid":{"rendered":"https:\/\/pheonixsolutions.com\/blog\/?p=5896"},"modified":"2026-11-18T15:20:39","modified_gmt":"2026-11-18T09:50:39","slug":"mail-configuration-using-the-smtp-gsuite-realy-service","status":"publish","type":"post","link":"https:\/\/pheonixsolutions.com\/blog\/mail-configuration-using-the-smtp-gsuite-realy-service\/","title":{"rendered":"Mail Configuration Using the Google Workspace SMTP Relay Service with Exim"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\"><strong><strong>Post Date:<\/strong><\/strong> November 16, 2020<strong><br><strong>Last Updated:<\/strong> <\/strong>November 17, 2026<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Introduction<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Email communication is essential for websites, applications, and business operations. Linux servers commonly send automated emails for password resets, contact forms, application notifications, system alerts, and other important activities.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Google Workspace provides an <a href=\"https:\/\/support.google.com\/a\/thread\/338685921\/smtp-relay?hl=en\" target=\"_blank\" rel=\"noopener\">SMTP <\/a>relay service that allows websites, applications, and mail servers to send outgoing emails through Google&#8217;s mail infrastructure. By configuring <a href=\"https:\/\/knowledge.workspace.google.com\/admin\/gmail\/advanced\/route-outgoing-smtp-relay-messages-through-google\" target=\"_blank\" rel=\"noopener\">Google Workspace SMTP relay<\/a> with Exim, you can improve email delivery reliability and securely route outgoing emails from your Linux server.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In this guide, we will explain how to configure the Google Workspace SMTP relay service with Exim on a Linux server. We will cover Google Admin Console settings, SMTP relay authentication, TLS encryption, firewall configuration, Exim configuration, and email testing.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Prerequisites<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Before configuring Google Workspace SMTP relay, ensure that you have:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>An active Google Workspace account.<\/li>\n\n\n\n<li>Access to the Google Workspace Admin Console.<\/li>\n\n\n\n<li>A Linux server with Exim installed.<\/li>\n\n\n\n<li>A static public IP address for IP-based authentication.<\/li>\n\n\n\n<li>Root or sudo access to the Linux server.<\/li>\n\n\n\n<li>Access to configure firewall rules.<\/li>\n\n\n\n<li>A verified domain configured in Google Workspace.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Step 1: Configure Google Workspace SMTP Relay Service<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">First, configure the SMTP relay service in the Google Workspace Admin Console.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">1. Sign in to Google Admin Console<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Open the Google Admin Console using your administrator account:<\/p>\n\n\n\n<figure class=\"wp-block-embed\"><div class=\"wp-block-embed__wrapper\">\nhttps:\/\/admin.google.com\n<\/div><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2020\/11\/image-5.png\"><img fetchpriority=\"high\" decoding=\"async\" width=\"384\" height=\"442\" src=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2020\/11\/image-5.png\" alt=\"Google Workspace Admin Console login using administrator account\n\" class=\"wp-image-13629\" srcset=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2020\/11\/image-5.png 384w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2020\/11\/image-5-261x300.png 261w\" sizes=\"(max-width: 384px) 100vw, 384px\" \/><\/a><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">2. Navigate to Gmail Advanced Settings<\/h3>\n\n\n\n<ol start=\"1\" class=\"wp-block-list\">\n<li>Navigate to <strong>Apps<\/strong>.<\/li>\n\n\n\n<li>Select <strong>Google Workspace<\/strong>.<\/li>\n\n\n\n<li>Select <strong>Gmail<\/strong>.<\/li>\n\n\n\n<li>Open <strong>Routing<\/strong>.<\/li>\n\n\n\n<li>Locate the <strong>SMTP relay service<\/strong> setting.<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2020\/11\/Google-Admin-Gmail-Routing-Guide.png\"><img decoding=\"async\" width=\"1024\" height=\"524\" src=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2020\/11\/Google-Admin-Gmail-Routing-Guide-1024x524.png\" alt=\"Google Workspace Admin Console login using administrator account\" class=\"wp-image-13630\" srcset=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2020\/11\/Google-Admin-Gmail-Routing-Guide-1024x524.png 1024w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2020\/11\/Google-Admin-Gmail-Routing-Guide-300x154.png 300w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2020\/11\/Google-Admin-Gmail-Routing-Guide-768x393.png 768w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2020\/11\/Google-Admin-Gmail-Routing-Guide-1536x786.png 1536w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2020\/11\/Google-Admin-Gmail-Routing-Guide.png 1752w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">3. Configure SMTP Relay Service<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Under the SMTP relay service section:<\/p>\n\n\n\n<ol start=\"1\" class=\"wp-block-list\">\n<li>Click <strong>Configure<\/strong> or edit the existing SMTP relay setting.<\/li>\n\n\n\n<li>Enter a suitable description for the relay configuration.<\/li>\n\n\n\n<li>Configure the allowed senders.<\/li>\n\n\n\n<li>Select the required authentication method.<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\">4. Configure Allowed Senders<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Under the Allowed senders section, choose the appropriate option based on your requirements:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Only registered Apps users in my domains:<\/strong> Allows registered Google Workspace users to send emails.<\/li>\n\n\n\n<li><strong>Only addresses in my domains:<\/strong> Allows email addresses belonging to your verified domains.<\/li>\n\n\n\n<li><strong>Any addresses:<\/strong> Allows any sender address. This option is not recommended unless specifically required.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">For most business environments, use a domain-restricted sender option to prevent unauthorized email sending.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">5. Configure Authentication<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Under the Authentication section, configure the authentication method.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Google Workspace supports the following authentication options:<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Option A: Only accept mail from specified IP addresses<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">This option allows Google Workspace to identify your server using its public IP address.<\/p>\n\n\n\n<ol start=\"1\" class=\"wp-block-list\">\n<li>Enable <strong>Only accept mail from the specified IP addresses<\/strong>.<\/li>\n\n\n\n<li>Click <strong>Add IP range<\/strong>.<\/li>\n\n\n\n<li>Enter a description for the server.<\/li>\n\n\n\n<li>Enter your server&#8217;s public IP address.<\/li>\n\n\n\n<li>Enable the IP address entry.<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><code>123.123.123.123<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Replace the example IP address with your actual server&#8217;s public IP address.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For security reasons, authorize only the required IP addresses.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Option B: Require SMTP Authentication<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">You can also enable SMTP authentication if your server or application requires it.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">When SMTP authentication is enabled, configure the appropriate authentication credentials on your SMTP client and ensure that the connection uses TLS.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For this guide, we will use IP-based authentication with a static public IP address.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">6. Enable TLS Encryption<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Under the Encryption section:<\/p>\n\n\n\n<ol start=\"1\" class=\"wp-block-list\">\n<li>Enable <strong>Require TLS encryption<\/strong>.<\/li>\n\n\n\n<li>This ensures that communication between your server and Google&#8217;s SMTP relay is encrypted.<\/li>\n\n\n\n<li>Click <strong>Save<\/strong>.<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">Finally, save the SMTP relay configuration in the Google Admin Console.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step 2: Configure Firewall Rules to Allow Outbound SMTP Traffic<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Your Linux server must be able to establish an outbound connection to Google&#8217;s SMTP relay server.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In this guide, we will use TCP port <strong>587<\/strong> with STARTTLS encryption.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Configure Google Cloud Firewall<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">If your Linux server is hosted on Google Cloud Platform, follow these steps:<\/p>\n\n\n\n<ol start=\"1\" class=\"wp-block-list\">\n<li>Log in to the Google Cloud Console.<\/li>\n\n\n\n<li>Navigate to <strong>VPC Network \u2192 Firewall<\/strong>.<\/li>\n\n\n\n<li>Click <strong>Create Firewall Rule<\/strong>.<\/li>\n\n\n\n<li>Enter a suitable name for the firewall rule.<\/li>\n\n\n\n<li>Select the network hosting your VM instance.<\/li>\n\n\n\n<li>Under Direction of traffic, select <strong>Egress<\/strong>.<\/li>\n\n\n\n<li>Select the appropriate target instances or network tags.<\/li>\n\n\n\n<li>Under Destination filter, configure the required destination range.<\/li>\n\n\n\n<li>Under Protocols and ports, select <strong>Specified protocols and ports<\/strong>.<\/li>\n\n\n\n<li>Select TCP and enter <code>587<\/code>.<\/li>\n\n\n\n<li>Click <strong>Create<\/strong>.<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">Verify that your firewall configuration allows outbound SMTP connections.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If you are using another cloud provider or a Linux firewall, ensure that outbound TCP port 587 is permitted.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step 3: Check and Install Exim on the Linux Server<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Connect to your Linux server through SSH.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Check whether Exim is installed:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">which exim<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Check the installed Exim version:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">exim -bV<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If Exim is not installed, install it according to your Linux distribution.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For Ubuntu or Debian:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">apt update\napt install exim4 -y<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Check the Exim service status:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">systemctl status exim4<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">On distributions using the <code>exim<\/code> service name, use:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">systemctl status exim<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Step 4: Configure Exim to Use Google Workspace SMTP Relay<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">After confirming that Exim is installed, configure it to route outgoing emails through Google Workspace SMTP relay.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The configuration file location may vary depending on your Linux distribution.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For systems using a traditional Exim configuration file, the configuration is commonly located at:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/etc\/exim\/exim.conf<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">1. Back Up the Existing Exim Configuration<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Before making any changes, create a backup:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">cp \/etc\/exim\/exim.conf \/etc\/exim\/exim.conf.bak<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">2. Configure the SMTP Router<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Open the Exim configuration file:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">nano \/etc\/exim\/exim.conf<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Search for:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">begin routers<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Add the following router configuration under this section:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">send_via_google:\n  driver = manualroute\n  domains = ! +local_domains\n  transport = google_smtp\n  route_list = * smtp-relay.gmail.com<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Make sure this router is placed before the general-purpose router that handles outgoing DNS routing, so messages intended for external domains are routed through Google SMTP relay.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Router Configuration Explanation<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>send_via_google<\/code>: Defines the router name.<\/li>\n\n\n\n<li><code>driver = manualroute<\/code>: Routes outgoing emails through a specified SMTP server.<\/li>\n\n\n\n<li><code>domains = ! +local_domains<\/code>: Applies the router to non-local destination domains.<\/li>\n\n\n\n<li><code>transport = google_smtp<\/code>: Specifies the SMTP transport.<\/li>\n\n\n\n<li><code>route_list<\/code>: Routes outgoing emails through Google&#8217;s SMTP relay server.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">3. Configure the SMTP Transport<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Search for:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">begin transports<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Add the following configuration:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">google_smtp:\n  driver = smtp\n  port = 587\n  hosts_require_tls = *<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Transport Configuration Explanation<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>driver = smtp<\/code>: Uses Exim&#8217;s SMTP transport.<\/li>\n\n\n\n<li><code>port = 587<\/code>: Connects to Google&#8217;s SMTP relay using port 587.<\/li>\n\n\n\n<li><code>hosts_require_tls = *<\/code>: Requires TLS encryption for the SMTP connection.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">4. Configure SMTP Authentication<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">For this configuration, we are using IP-based authentication. Therefore, you do not need to configure a Google username and password in Exim.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Google Workspace identifies the server using the public IP address authorized in the SMTP relay settings.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If you choose SMTP authentication instead, configure the appropriate supported authentication method and securely store the credentials.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Avoid storing plain-text passwords in publicly readable configuration files.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">5. Restart Exim<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">After completing the configuration, validate the Exim configuration:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">exim -bV<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Restart Exim:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">systemctl restart exim4<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If your distribution uses the <code>exim<\/code> service name:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">systemctl restart exim<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Check the service status:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">systemctl status exim4<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Step 5: Test the Google Workspace SMTP Relay Connection<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">After configuring Exim, verify that your Linux server can establish a secure connection to Google&#8217;s SMTP relay.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Run:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">openssl s_client -starttls smtp -connect smtp-relay.gmail.com:587 -crlf<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If the connection is successful, you should see the SMTP server response and TLS certificate information.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">You can also test network connectivity using:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">nc -vz smtp-relay.gmail.com 587<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">A successful connection indicates that the server can reach the SMTP relay on the configured port.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step 6: Send a Test Email<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Once the SMTP relay connection is working, send a test email from your Linux server.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Run:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">echo \"This is a test email from the Google Workspace SMTP relay configuration.\" | mail -s \"SMTP Relay Test\" recipient@example.com<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Replace <code>recipient@example.com<\/code> with the actual recipient email address.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If the <code>mail<\/code> command is not installed, install the required mail utility package for your Linux distribution.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Check the Exim mail queue:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">exim -bp<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Check Exim logs:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For Ubuntu or Debian:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">tail -f \/var\/log\/exim4\/mainlog<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">For other distributions, the log may be located at:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">tail -f \/var\/log\/exim\/mainlog<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If the message is accepted and delivered successfully, your Google Workspace SMTP relay configuration is working.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step 7: Troubleshoot Common SMTP Relay Issues<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">If your emails are not being delivered, check the following common issues.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">1. Relay Access Denied<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Possible reason:<\/strong> The server&#8217;s public IP address is not registered in Google Workspace SMTP relay settings.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Solution:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Verify the server&#8217;s public IP address.<\/li>\n\n\n\n<li>Check the authorized IP address in Google Admin Console.<\/li>\n\n\n\n<li>Confirm that the sending domain is configured correctly.<\/li>\n\n\n\n<li>Verify that the envelope sender and sender domain are permitted.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">2. Connection Timed Out<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Possible reason:<\/strong> Outbound SMTP traffic is blocked by the server firewall, cloud firewall, or hosting provider.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Solution:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Verify outbound TCP port 587.<\/li>\n\n\n\n<li>Check cloud firewall egress rules.<\/li>\n\n\n\n<li>Confirm that your hosting provider allows SMTP connections.<\/li>\n\n\n\n<li>Test connectivity using <code>nc<\/code> or OpenSSL.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">3. TLS Connection Failed<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Possible reason:<\/strong> TLS configuration or certificate validation issues.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Solution:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Check that OpenSSL is installed.<\/li>\n\n\n\n<li>Verify the server&#8217;s system date and time.<\/li>\n\n\n\n<li>Confirm that TLS is enabled in the Exim transport.<\/li>\n\n\n\n<li>Test the connection using OpenSSL.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">4. Emails Are Not Appearing in the Recipient&#8217;s Inbox<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Possible reason:<\/strong> The email may have been rejected, filtered as spam, or delayed.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Solution:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Check Exim mail logs.<\/li>\n\n\n\n<li>Verify SPF, DKIM, and DMARC DNS records.<\/li>\n\n\n\n<li>Review Google Workspace Email Log Search.<\/li>\n\n\n\n<li>Check the recipient&#8217;s spam folder.<\/li>\n\n\n\n<li>Verify that the sending IP and domain have a good reputation.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">5. SMTP Authentication or IP Validation Error<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Possible reason:<\/strong> The server is sending through an IP address that is not authorized in Google Workspace SMTP relay settings.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Solution:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Verify the server&#8217;s public IP address.<\/li>\n\n\n\n<li>Update the SMTP relay IP allowlist.<\/li>\n\n\n\n<li>Check the sender domain.<\/li>\n\n\n\n<li>Verify the SMTP relay authentication settings.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Best Practices for Google Workspace SMTP Relay<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Follow these security and email delivery best practices:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Use a static public IP address for IP-based authentication.<\/li>\n\n\n\n<li>Enable TLS encryption for outgoing SMTP connections.<\/li>\n\n\n\n<li>Avoid storing account passwords in plain-text configuration files.<\/li>\n\n\n\n<li>Restrict SMTP relay access to authorized IP addresses.<\/li>\n\n\n\n<li>Configure SPF, DKIM, and DMARC for your sending domain.<\/li>\n\n\n\n<li>Monitor Exim mail logs regularly.<\/li>\n\n\n\n<li>Keep Exim and the Linux operating system updated.<\/li>\n\n\n\n<li>Follow Google Workspace SMTP relay sending limits and policies.<\/li>\n\n\n\n<li>Use a valid sender address belonging to your authorized domain.<\/li>\n\n\n\n<li>Review email delivery and spam reports regularly.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Configuring Google Workspace SMTP relay with Exim provides a reliable way to send outgoing emails from Linux servers, websites, and applications. By configuring the SMTP relay service in the Google Admin Console, authorizing your server&#8217;s public IP address, enabling TLS encryption, and updating the Exim router and transport settings, you can establish a secure email delivery solution.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">It is also important to configure SPF, DKIM, and DMARC records, monitor mail server logs, and regularly review SMTP relay permissions to maintain email security and improve email deliverability.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If you need professional assistance with Google Workspace SMTP relay configuration, Exim mail server setup, email troubleshooting, or Linux server administration, Pheonix Solutions provides reliable infrastructure and server management services to help your business maintain secure and efficient email communication.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Frequently Asked Questions (FAQs)<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">1. What is Google Workspace SMTP relay service?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Google Workspace SMTP relay service allows websites, applications, and mail servers to send outgoing emails through Google&#8217;s SMTP infrastructure. It supports IP-based authentication and SMTP authentication, depending on the configured settings.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">2. Which SMTP server and port are used for Google Workspace SMTP relay?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The Google Workspace SMTP relay hostname is <code>smtp-relay.gmail.com<\/code>. Port 587 is commonly used with STARTTLS encryption. Other supported connection options depend on Google&#8217;s SMTP relay configuration and your server&#8217;s requirements.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">3. Can I configure Google Workspace SMTP relay with Exim on Linux?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Yes. You can configure Exim to route outgoing emails through Google Workspace SMTP relay. You need to configure the Exim router, SMTP transport, TLS encryption, and the appropriate authentication method.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Related Articles<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/pheonixsolutions.com\/blog\/setup-postfix-with-mailgun-for-reliable-e-mail-delivery-on-ubuntu\/\">Setup Postfix with Mailgun for Reliable Email Delivery on Ubuntu<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/pheonixsolutions.com\/blog\/postfix-delayed-mail-delivery\/\">How to Fix Postfix Delayed Mail Delivery: A Complete Troubleshooting Guide<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Need Help Integrating SendGrid with Postfix?<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Looking to configure SendGrid SMTP relay, troubleshoot email delivery issues, or manage outgoing email services on your Linux server?<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/pheonixsolutions.com\/blog\/\">Pheonix Solutions<\/a> provides Linux server administration, email server configuration, SMTP integration, cloud hosting, server security, and infrastructure management services.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Our team can help you configure Postfix, integrate SendGrid SMTP relay, troubleshoot email authentication failures, resolve email delivery issues, configure secure mail services, and maintain your Linux server environment efficiently.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/pheonixsolutions.com\/contact\/?utm_source=chatgpt.com\">Get in touch with our team<\/a> to discuss your email server integration and Linux server management requirements.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Post Date: November 16, 2020Last Updated: November 17, 2026 Introduction Email communication is essential for websites, applications, and business operations. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":13632,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_hide_featured_image":false,"_jetpack_featured_image_duplicate_dismissed":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[1019],"tags":[13,783,782,784],"class_list":["post-5896","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-cloud-aws","tag-exim","tag-gmail-suite","tag-mail-relay-setup","tag-setting-up-a-firewall","psol-cat-cloud-aws"],"jetpack_publicize_connections":[],"jetpack_shortlink":"https:\/\/wp.me\/phn2x7-1x6","jetpack_sharing_enabled":true,"jetpack_featured_media_url":"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2020\/11\/Google-Workspace-SMTP-Relay-with-Exim.png","_links":{"self":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/5896","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/comments?post=5896"}],"version-history":[{"count":2,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/5896\/revisions"}],"predecessor-version":[{"id":13634,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/5896\/revisions\/13634"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/media\/13632"}],"wp:attachment":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=5896"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=5896"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=5896"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}