IonfirmDOCS
Docssmart_ai_contactform Guide
smart_ai_contactform/Docs

SMTP Email Setup

How to configure secure email routing so fallback support requests reach your inbox.

SMTP Email Setup

While the AI will handle the majority of basic questions, there will always be users who need complex help, or who simply request to speak to a human.

When this happens, the script needs to send an email alert to you containing the user's details and their question. To ensure these emails actually reach your inbox (and don't end up in the spam folder), the Smart AI Contact Form uses PHPMailer and SMTP authentication.

💡 Why SMTP instead of PHP mail()? Standard PHP mail() is notorious for being flagged as spam by Gmail and Outlook because it lacks proper authentication. By using SMTP, the script logs into your email server like a real user, guaranteeing high deliverability.

Configuring your .env File

If you haven't already, open your .env file (located in the root folder of your script) and locate the Email Settings section.

# --- EMAIL SETTINGS (SMTP) ---
SMTP_HOST=smtp.yourhost.com
SMTP_PORT=465
SMTP_USER=support@yourdomain.com
SMTP_PASS="your_email_password"
 
SMTP_FROM_EMAIL=noreply@yourdomain.com
SMTP_FROM_NAME="AI Smart Form"
 
SUPPORT_EMAIL=admin@yourdomain.com

What do these variables mean?

  • SMTP_HOST: Your outgoing mail server. If you use cPanel, this is often mail.yourdomain.com. If you use Google Workspace, it is smtp.gmail.com.
  • SMTP_PORT: Usually 465 (for SSL) or 587 (for TLS).
  • SMTP_USER: The email address you are using to send the email.
  • SMTP_PASS: The password for that email address. (Note: If using Gmail, see the "App Passwords" section below).
  • SMTP_FROM_EMAIL: This should usually be exactly the same as your SMTP_USER to prevent spam filters from blocking the message for "spoofing".
  • SUPPORT_EMAIL: The destination address. Where do you want the lead sent? (e.g., your personal inbox).

The "Reply-To" Magic

You might be wondering: "If the email is sent from my own SMTP server, won't replying to it just send an email to myself?"

No! We have engineered the script to automatically inject the visitor's email address into the Reply-To header. When you receive a support ticket and hit "Reply" in your email client (Gmail, Outlook, Apple Mail), your reply will automatically go straight to the customer.

Finding your SMTP Details

If you aren't sure what your SMTP details are, here is how to find them based on your provider:

Standard Web Hosting (cPanel / Hostinger / GoDaddy)

  1. Log into your hosting control panel.
  2. Go to the Email Accounts section.
  3. Click "Connect Devices" or "Client Setup" next to your email address.
  4. Look for the "Outgoing Server" (SMTP) details. Use the SSL/TLS recommended settings.

Using Gmail or Google Workspace

Google no longer allows you to use your standard account password for third-party scripts. You must generate an "App Password".

  1. Go to your Google Account Management page.
  2. Navigate to Security and enable 2-Step Verification.
  3. Once enabled, search for App Passwords.
  4. Generate a new password (name it "AI Form").
  5. Google will give you a 16-character password. Paste this exact password into the SMTP_PASS field in your .env file. Your SMTP_HOST will be smtp.gmail.com and the port will be 465.

Using Transactional Email (SendGrid / Mailgun / Brevo)

If you send high volumes of emails, you can use a dedicated service.

  1. Obtain your SMTP credentials from your provider's dashboard.
  2. For SendGrid, the username is usually apikey and the password is the API key itself.