Send e-mails through Gmail

Use a Gmail account and an app password as the SMTP server for your application.

An application running on your website can send e-mails through the SMTP server of Gmail. This is the way to send e-mails on the Free plan, where our local SMTP server is not available.

SMTP settings

Setting Value
SMTP server smtp.gmail.com
Port 587
Username Your Gmail address, your-mail-address@gmail.com
Password A Gmail app password
SSL (EnableSsl) On

Important

Do not use the regular password of your Gmail account. Create an app password in your Google account instead — it is designed for this purpose and is more secure.

Create a Gmail app password

Open myaccount.google.com/apppasswords, create an app password and use it as the SMTP password in your application.

Example in .NET

using System.Net;
using System.Net.Mail;

// Gmail SMTP server settings
var smtpServer = "smtp.gmail.com";
var smtpPort = 587;
var enableSsl = true;

// Gmail login credentials
var gmailUsername = "your-mail-address@gmail.com";
var gmailPassword = "your-app-password"; // the app password, not your regular password

// E-mail message
var fromEmail = "your-mail-address@gmail.com"; // must match the Gmail username
var toEmail = "recipient@example.com";
var subject = "Test e-mail via Gmail SMTP";
var body = "This is a test e-mail sent using Gmail SMTP and .NET.";

var mail = new MailMessage(fromEmail, toEmail, subject, body);

var smtp = new SmtpClient(smtpServer, smtpPort);
smtp.EnableSsl = enableSsl;
smtp.UseDefaultCredentials = false;
smtp.Credentials = new NetworkCredential(gmailUsername, gmailPassword);

try
{
    smtp.Send(mail);
    Response.Write("E-mail sent successfully.");
}
catch (Exception ex)
{
    Response.Write("Error sending e-mail: " + ex.Message);
}

The sender address must be the same as the Gmail username.

Protect your contact form

Never publish a contact form without protection. Bots can fill in an unprotected form thousands of times, which sends spam, wastes server resources and can cause real problems. Add an anti-bot check to every public form, for example:

  • Google reCAPTCHA — easy to add and blocks most spam bots.
  • Cloudflare Turnstile — a free, privacy-friendly alternative to CAPTCHA.
Still stuck? Our support team is happy to help.
Ask the community Open a support ticket