Home • Blog • Article

How to Connect SiteGround Email to Website Contact Form?

By Fathima Nourin TM • •

Architecting Secure Mail Delivery: Connecting SiteGround SMTP to WordPress Contact Forms

Managing a robust web application infrastructure requires ensuring that internal communication channels, automated alerts, and user-facing interaction pipelines operate without degradation or data loss. When a WordPress website is hosted on SiteGround and utilizes proprietary mailbox configurations, the standard delivery mechanisms provided out of the box frequently fail to meet production-grade reliability standards. Bridging the gap between a frontend contact form and a backend mail server requires implementing authenticated Simple Mail Transfer Protocol (SMTP) channels rather than relying on unauthenticated, native server transport functions.

This technical guide details the comprehensive process of configuring, securing, and validating a SiteGround mailbox connection to a WordPress contact form infrastructure, ensuring zero message loss, strict SPF/DKIM alignment, and robust cryptographic transmission protocols.

Problem Statement & Impact

The core technical challenge in WordPress email delivery stems from the legacy default behavior of the PHP execution environment. Out of the box, WordPress invokes the PHP mail() function to dispatch transactional notifications, password resets, and contact form submissions. This function instructs the local web server daemon (such as Postfix or Exim running on the hosting node) to send an email directly without formal cryptographic validation or external relay authentication.

🚨 Facing an active site error or malware warning?

Chat with an engineer on WhatsApp within 15 minutes.

💬 Chat on WhatsApp

In modern enterprise and shared hosting environments like SiteGround, this direct-dispatch approach introduces catastrophic operational failures:

  • Reputational Degradation and Spam Flagging: Major mailbox providers (Google Workspace, Microsoft 365, Yahoo) enforce strict inbound filtering algorithms. Emails originating from a web server via PHP mail() often lack proper Sender Policy Framework (SPF) and DomainKeys Identified Mail (DKIM) alignment with the sending domain, causing recipient servers to classify them as spam or reject them entirely.
  • IP Blacklisting Risks: Shared hosting nodes house multiple tenants. If an unauthenticated script on a neighboring virtual host triggers spam flags, the server’s shared IP address can be blacklisted. When WordPress attempts to use the local MTA (Mail Transfer Agent) via PHP mail(), messages fail across all domains hosted on that node.
  • Complete Delivery Silent Failures: PHP mail() returns a boolean value (`true` or `false`) based solely on whether the local MTA accepted the message into its queue. It provides no visibility into whether the receiving mail server accepted, bounced, or dropped the packet, leading to silent drops of critical business leads.

The business consequence of inaction is direct revenue loss and degraded operational responsiveness. Unreceived contact inquiries translate to abandoned customer acquisitions, while missed system-critical alerts leave administrators blind to security incidents or database failures.

Root Cause Analysis & Architecture

To understand why SMTP integration resolves these communication faults, we must examine the email transit lifecycle. When a user submits a contact form (via plugins such as Contact Form 7, WPForms, or Fluent Forms), the application generates a MIME-compliant email payload containing the sender’s address, recipient, headers, and body content.

Under the unauthenticated model, the application hands this payload to the local PHP runtime:


// The insecure, default method using unauthenticated local MTA
$to = "[email protected]";
$subject = "New Contact Form Submission";
$message = "Name: John Doe\nMessage: Hello world";
$headers = "From: [email protected]";

// This bypasses proper authentication and triggers spam filters
mail($to, $subject, $message, $headers);

Because the From address domain does not match the actual envelope sender authenticated by the local server’s PTR record and server hostname, receiving mail transfer agents flag the message as a forgery (spoofing attempt).

The architectural solution is to insert an explicit SMTP transport layer between the WordPress application and the SiteGround mail cluster. Instead of relying on local loopback mechanisms, WordPress establishes a TCP or TLS-encrypted socket connection directly to SiteGround’s outbound mail servers (e.g., smtp.gim.siteground.biz or the specific server hostname assigned to the account).

This authenticated session enforces the following cryptographic and protocol standards:

  1. TCP Handshake & TLS Negotiation: The application initiates a secure connection over port 465 (SMTPS) or port 587 (SMTP with STARTTLS).
  2. SASL Authentication: The application presents explicit Simple Authentication and Security Layer (SASL) credentials—specifically, the full SiteGround mailbox username and master application password.
  3. Envelope Alignment: The authenticated user matches the header From address, ensuring that SPF checks executed by external mail exchangers validate successfully against SiteGround’s published DNS records.

Step-by-Step Implementation & Remediation Guide

Implementing reliable SMTP relay integration requires gathering specific mailbox identifiers, deploying a robust abstraction plugin to override WordPress core mail functions, configuring cryptographic parameters, and executing programmatic validation.

Step 1: Extracting SiteGround Mailbox Parameters

Administrative access to SiteGround Site Tools is required to retrieve the exact routing parameters for the designated mailbox.

  1. Log in to the SiteGround User Area and navigate to Sites > Site Tools for the target domain.
  2. In the left-hand navigation menu, select Site > Email Accounts.
  3. Locate the target mailbox within the account list, click the vertical three-dot options menu, and select Mail Client Manual Settings.
  4. Record the following parameters exactly as displayed:
    • Outgoing Mail Server (SMTP Host): Typically formatted as mail.yourdomain.com or a server-specific hostname such as sgsXX.siteground.biz.
    • SMTP Port: Use 465 for explicit SSL/TLS or 587 for STARTTLS.
    • SMTP Username: The complete email address (e.g., [email protected]).
    • SMTP Password: The cryptographic password generated specifically for this mailbox.

Step 2: Provisioning the SMTP Abstraction Layer

Because WordPress core lacks native configuration fields for external SMTP relays, an enterprise-grade mail delivery plugin must be installed. WP Mail SMTP or FluentSMTP are industry standards that override the pluggable wp_mail() function.

Deploy the plugin via WP-CLI to ensure clean execution without administrative dashboard overhead:


# Navigate to the WordPress root directory
cd /var/www/vhosts/yourdomain.com/httpdocs

# Install and activate WP Mail SMTP via WP-CLI
wp plugin install wp-mail-smtp --activate --path=./

Step 3: Configuring Cryptographic and Relay Directives

Configure the plugin to route all outbound application emails through the SiteGround mail cluster using secure authentication directives. This can be executed via the WordPress administrative UI or programmatically by defining constants within the wp-config.php file to prevent administrative tampering.

Add the following configuration constants directly into wp-config.php just above the /* That's all, stop editing! */ line:


/**
 * WP Mail SMTP Hardcoded Configuration Constants
 * Prevents UI modification and enforces SiteGround SMTP relay security.
 */
define( 'WPMS_ON', true );
define( 'WPMS_MAILER', 'smtp' );
define( 'WPMS_SMTP_HOST', 'sgsXX.siteground.biz' ); // Replace with exact SiteGround server hostname
define( 'WPMS_SMTP_PORT', 465 );
define( 'WPMS_SSL', 'ssl' ); // Options: 'ssl', 'tls', or '' (none)
define( 'WPMS_SMTP_AUTH', true );
define( 'WPMS_SMTP_USER', '[email protected]' );
define( 'WPMS_SMTP_PASS', 'YourSecureMailboxPassword123!' );
define( 'WPMS_MAIL_FROM', '[email protected]' );
define( 'WPMS_MAIL_FROM_NAME', 'Corporate Website Notifications' );
define( 'WPMS_SET_RETURN_PATH', true );

If utilizing the administrative graphical interface rather than configuration constants, ensure the following parameters are explicitly mapped:

  • Mailer: Other SMTP
  • SMTP Host: Insert the exact SiteGround server hostname.
  • Encryption: SSL (recommended for port 465) or TLS (recommended for port 587).
  • SMTP Port: 465 or 587 matching the chosen encryption type.
  • Auto TLS: Enabled.
  • Authentication: Enabled.
  • SMTP Username: Full mailbox address.
  • SMTP Password: Mailbox password.

Step 4: Executing Programmatic Diagnostic Validation

Verify the mail pipeline by triggering a diagnostic test payload directly from the terminal using WP-CLI, ensuring the socket connection, SSL handshake, and SASL authentication complete without error.


# Execute a test email dispatch to verify SMTP relay operational status
wp wp-mail-smtp send-test [email protected] --path=./

A successful execution returns a confirmation string verifying that the TCP handshake on port 465/587 completed and the SiteGround MTA accepted the authentication token.

Production Hardening & Edge Cases

Deploying an SMTP relay in a high-traffic production environment introduces subtle architectural interactions, caching conflicts, and performance overheads that must be mitigated.

Handling Firewall and Outbound Port Restrictions

Many managed cloud providers and strict VPS firewalls block outbound connections on ports 25, 465, and 587 by default to prevent spam propagation by compromised scripts. If the SMTP connection hangs or times out during the test phase, verify outbound firewall rules at the host network layer.

Test the TCP socket connectivity directly from the server command line using nc (Netcat) or openssl:


# Test raw SSL socket connectivity to the SiteGround mail server
openssl s_client -connect sgsXX.siteground.biz:465

If the connection is refused or times out, submit a network infrastructure ticket to unblock outbound TCP port 465 or 587 to the specific SiteGround mail exchanger IP address.

Asynchronous Queue Processing for High-Volume Forms

Synchronous SMTP connections block the HTTP worker thread during form submission. When a user submits a contact form, the PHP process must open a TCP socket, complete the TLS handshake, authenticate via SASL, transmit the MIME packet, and wait for the remote server’s 250 OK response code before rendering the success page to the browser. This synchronous wait can introduce latency of 1 to 3 seconds, increasing Time to First Byte (TTFB) and risking gateway timeouts under high concurrency.

To optimize performance, configure your SMTP plugin to leverage asynchronous background processing queues or leverage WordPress Action Scheduler:

  • Ensure background task runners (such as WP-Cron) are invoked via real system cron jobs rather than web-traffic triggers.
  • Configure the SMTP plugin to queue outgoing emails into database tables and dispatch them via asynchronous background worker processes.

DNS Record Alignment (SPF, DKIM, DMARC)

Even with correct SMTP authentication, emails may be rejected if the domain’s public DNS records lack proper authentication directives pointing to SiteGround. Verify that the domain’s DNS zone contains an active SPF record authorizing SiteGround’s infrastructure:


v=spf1 include:spf.siteground.com ~all

Additionally, ensure that DKIM signing is enabled within your SiteGround Site Tools under Email > Authentication to cryptographically sign every outbound message generated by the contact form.

Diagnostic Verification & Checklist

Post-implementation validation must be conducted systematically to confirm that all technical parameters meet enterprise security and operational standards.

Verification Step Diagnostic Tool / Command Expected Result Failure Action / Mitigation
DNS SPF Record Check dig TXT yourdomain.com Includes include:spf.siteground.com Update DNS zone file to append SiteGround SPF mechanisms.
TCP Socket Test nc -zv sgsXX.siteground.biz 465 Connection to sgsXX.siteground.biz 465 port [tcp/*] succeeded! Check host firewall rules; request outbound port unblocking from hosting provider.
SMTP Authentication Test WP-CLI Test Command “Test email was sent successfully!” with 250 OK response code Verify username, password, and port encryption parameters in wp-config.php.
End-to-End Form Delivery Frontend DOM Submission Message received in inbox within 5 seconds with zero spam flagging Check DKIM keys in SiteGround Site Tools and review spam filter headers.

Maintaining a secure, high-performance website infrastructure requires continuous monitoring of mail server error logs, server resource utilization, and application security hardening. For comprehensive oversight of your digital assets, regular vulnerability assessments, and managed security protocols, explore the advanced technical frameworks and monitoring solutions provided by SiteSuraksha.

Follow SiteSuraksha on Google
Add us to your preferred sources for verified WordPress & hosting guides.
FREE 30-SECOND DIAGNOSTIC

Is Your Website Fast & Secure?

Run an instant scan for security vulnerabilities, bloated plugins, and TTFB latency.

🔍 Test Your Site Now →
Map Your Issue to Guaranteed IT Care
Security & Malware
Hacks, 0-day exploits & backup failures
Pro Care (₹5,420/mo) →
Speed & Cloud Bills
Slow checkout, high TTFB & cloud waste
Pro Care (₹5,420/mo) →
ERP & Automation
GST pipelines, RPA & AI support agents
Enterprise (₹14,999/mo) →
EXPERT WORDPRESS CARE

Need Help Securing or Speeding Up Your Site?

Get 24/7 proactive security WAF, daily cloud backups, and sub-second speed optimization from ₹3,470/mo.

💬 Chat on WhatsApp Explore Plans
← Back to All Articles