For AI agents: the complete documentation index is available at https://docs.ovhcloud.com/en/llms.txt, the full documentation bundle is available at https://docs.ovhcloud.com/en/llms-full.txt, and this page is available as Markdown at https://docs.ovhcloud.com/en/guides/web-cloud/web-hosting/email-sending-best-practices.md.

Web Hosting - Email sending best practices

View as Markdown

Choose between PHP mail() and authenticated SMTP to send emails from your web hosting plan, and configure SMTP with your OVHcloud email account

Objective

Your web hosting plan offers two ways of sending emails from your website: the native PHP mail() function, which uses the outgoing mail servers of your hosting plan, and authenticated SMTP through an email account attached to your domain. Both are legitimate. mail() is the default method: it needs no configuration, is subject to a quota per hosting plan and is monitored from your OVHcloud Control Panel. Authenticated SMTP is the alternative when you need to control the sender identity: the From: address is bound to an authenticated account and the email carries your domain's signature. Its quotas apply per email account and per source IP address, shared across the hosting cluster.

This guide helps you choose between the two methods and explains how to configure authenticated SMTP sending from a shared hosting plan, whether you manage a WordPress site, another CMS, or a PHP application.

Requirements


OVHcloud Control Panel Access

  • Direct link:
  • Navigation path: Web Cloud > Hosting plans > Select your web hosting plan

Instructions

1. mail() or authenticated SMTP: which one should you use?

Both methods send emails from your website. They differ in:

  • the server the email is sent from,
  • the sending limits,
  • how you monitor them.
PHP mail()Authenticated SMTP
How it worksThe script hands the email to the outgoing mail servers of your hosting plan. No configuration is needed.The script connects to the OVHcloud mail server with the login and password of an email account attached to your domain.
Sending quotaPer hosting plan and per hour, depending on your offer. See the technical specifications of web hosting plans.Per email account and per hour (around 200 emails for an MX Plan account), plus 300 emails per hour per source IP address on the OVHcloud SMTP server. On a shared hosting plan, the outgoing IP address is shared with the other websites on the cluster.
MonitoringFrom the Email scripts tab of your hosting plan in the OVHcloud Control Panel: statistics, error reports, blocking and purging. See Monitoring and managing automated emails in your web hosting plan.Not visible in the OVHcloud Control Panel. Follow the sends from your application's logs.
Sender identityThe From: address is declared by the script. Its domain must be attached to your hosting plan (multisite), otherwise the email cannot be authenticated.The From: address must match the authenticated account. The email is signed with DKIM if DKIM is enabled for your domain.
Typical useContact forms, notifications, any script whose volume fits the plan quota.CMS with several plugins sending emails, applications that need a fixed and signed sender, or a From: address shared with your mailbox.

Whichever method you choose:

  • Recipient servers (Gmail, Outlook, etc.) check that the From: domain authorises the sending server. Keep your SPF, DKIM and DMARC records correct in your DNS zone.
  • Sending abuse or spam from your hosting plan or from your email account leads to an automatic block. If your emails are no longer sent, refer to the guide Monitoring and managing automated emails in your web hosting plan.
  • The total size of an email cannot exceed 10 MB, headers and encoding included.

Open forms: an abuse vector for both methods

A publicly accessible contact form with no protection mechanism is a prime target for bots. Bots exploit it to send thousands of emails in minutes, which gets the shared IP address blocked and harms every customer on the cluster.

Set up the following protections on any form that triggers an email:

  • Captcha: integrate a verification system (Google reCAPTCHA v3, hCaptcha, or a simple arithmetic challenge) to block automated submissions.
  • Rate limiting: limit the number of sends per IP address on the server side to prevent burst abuse.
  • Strict input validation: sanitise every form field before using it in an email — never trust user-supplied data.
Warning

The absence of a captcha on an open sending form is one of the most frequent causes of shared hosting being blocked for spam. This protection is essential whichever sending method you use.

2. Configuring authenticated SMTP with an OVHcloud email account

Principle

Send your emails through an authenticated SMTP connection to the OVHcloud mail server, using an email account attached to your domain (for example contact@mydomain.ovh).

This approach offers three major benefits:

  • Guaranteed authentication: the OVHcloud server verifies your identity before accepting the email.
  • SPF and DKIM: the email is issued by a server authorised for your domain and signed with DKIM if DKIM is enabled for your domain.
  • One identified account: every send is tied to a single email account, whose password you can change at any time to stop an abusive script or plugin.

Sending with mail(): the domain must be attached to your hosting plan

To send emails from your hosting plan with the PHP mail() function, the domain used in the From: field must be attached to your hosting plan.

This domain does not have to be managed in your OVHcloud account: you can use a domain registered with another registrar, as long as it is attached to your hosting plan, which is what proves you are authorised to send emails on its behalf.

Tip

If your domain is not attached to your hosting plan yet, add it as a multisite from your OVHcloud Control Panel, then check the associated DNS configuration. Refer to the guide Hosting multiple websites on your Web Hosting plan.

Warning

An email sent for a domain that is not attached to your hosting plan cannot be authenticated: it is treated as an unauthenticated send, and is therefore rejected and logged as an error.

Why the From: field must belong to your domain

The From: field of your email must contain an address belonging to your domain (for example contact@mydomain.ovh), and this address must match the SMTP account used for authentication.

If the From: does not match the domain authorised in the SPF record, or if the DKIM signature does not match, the recipient mail servers (Gmail, Outlook, etc.) may reject the email or classify it as spam.

Tip

To maximise deliverability, make sure the SPF, DKIM, and DMARC records are correctly configured in your DNS zone. Gmail and Yahoo Mail now require them for bulk senders. Refer to our guides:

Contact forms: fixed From: field and user Reply-To:

A common mistake is to put the address the user entered in the form straight into the From: field. For example, a visitor enters user@gmail.com and the script uses this address as the sender.

This behaviour is incorrect for two reasons:

  • Your domain's SPF record does not authorise Gmail servers (or any other third-party provider) to send on your behalf → SPF check failure.
  • You are sending "on behalf of" an address that does not belong to you → high risk of being classified as spam or rejected.

The correct pattern for a contact form:

Email fieldValueRole
From:contact@mydomain.ovh (fixed address of the site)Authenticated sender — never changes
Reply-To:Address entered by the user in the formAllows you to reply directly to the user
Subject:Message subject, prefixed (for example [Contact])Makes form messages easy to identify

When you reply, your mail client uses the Reply-To: address instead, without compromising SPF/DKIM authentication.

Here is how to adapt the PHPMailer example for a contact form:

// User-supplied data (validate and sanitise before use)
$userEmail = filter_var($_POST['email'], FILTER_VALIDATE_EMAIL);
$userName  = htmlspecialchars(strip_tags($_POST['name']));
$message   = htmlspecialchars(strip_tags($_POST['message']));

if (!$userEmail) {
    die('Invalid email address.');
}

// From: always fixed — your site's address, never the user's
$mail->setFrom('contact@mydomain.ovh', 'My Website');

// Reply-To: the user's address, so you can reply to them directly
$mail->addReplyTo($userEmail, $userName);

// Recipient: yourself (you receive the form message)
$mail->addAddress('contact@mydomain.ovh', 'My Website');

$mail->Subject = '[Contact] ' . $userName;
$mail->Body    = "Name: $userName\nEmail: $userEmail\n\nMessage:\n$message";
Tip

Never pass form data directly into PHPMailer without prior validation. Use filter_var() for the email address and htmlspecialchars() + strip_tags() for text fields to prevent email header injection.

OVHcloud SMTP settings

Use the following settings for your MX Plan email account (included with your web hosting):

SettingValue
SMTP serversmtp.mail.ovh.net
Port (SSL/TLS)465 (recommended)
Port (STARTTLS)587
EncryptionSSL/TLS (port 465) or STARTTLS (port 587)
AuthenticationRequired
UsernameFull email address (for example contact@mydomain.ovh)
PasswordPassword of the OVHcloud email account
Tip

For Email Pro or Exchange solutions, the SMTP server is different. Refer to the documentation for each solution for the exact settings.

Where to find your SMTP credentials

The SMTP username is your full email address (for example contact@mydomain.ovh).

The password is the one set when the address was created, or changed from the OVHcloud Control Panel. If you have forgotten it or want to reset it, refer to the guide Changing the password of an email account.

Warning

The MX Plan solution included with web hosting is subject to sending quotas (around 200 emails per hour per account), independent of the mail() quota of your hosting plan. The OVHcloud SMTP server also accepts at most 300 emails per hour per source IP address. On a shared hosting plan, this IP address is shared with the other websites hosted on the same cluster, so you reach the limit faster than from your own computer. Standard mailbox solutions are not designed for bulk sending: for high volumes — newsletters or bulk transactional emails — use a dedicated third-party transactional email service.

PHP code example with PHPMailer

PHPMailer is the reference PHP library for sending emails through SMTP. Install it via Composer:

composer require phpmailer/phpmailer

Here is a complete example of authenticated SMTP sending:

<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;
use PHPMailer\PHPMailer\Exception;

require 'vendor/autoload.php';

$mail = new PHPMailer(true);

try {
    // OVHcloud SMTP server settings
    $mail->isSMTP();
    $mail->Host       = 'smtp.mail.ovh.net';
    $mail->SMTPAuth   = true;
    $mail->Username   = 'contact@mydomain.ovh'; // Your OVHcloud email address
    $mail->Password   = 'your_password';         // Password of the email account
    $mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS; // SSL/TLS
    $mail->Port       = 465;

    // Sender: must belong to your domain
    $mail->setFrom('contact@mydomain.ovh', 'My Website');
    $mail->addReplyTo('contact@mydomain.ovh', 'My Website');

    // Recipient
    $mail->addAddress('mary.johnson@example.com', 'Recipient Name');

    // Content
    $mail->isHTML(true);
    $mail->Subject = 'Your email subject';
    $mail->Body    = 'Email body in <b>HTML</b>';
    $mail->AltBody = 'Email body in plain text (fallback)';

    $mail->send();
    echo 'Email sent successfully.';
} catch (Exception $e) {
    echo "Error while sending: {$mail->ErrorInfo}";
}
Warning

Never store your email account password in plain text in a versioned PHP file. Use a configuration file excluded from your Git repository (.gitignore).

Info

With this configuration, every email sent from your site is:

  • authenticated with the OVHcloud server,
  • authorised by your domain's SPF record and signed with DKIM if it is enabled,
  • issued by a single identified account, whose password you control.

3. WordPress and other CMSs: use an SMTP plugin

3.1 How WordPress sends emails by default

The wp_mail() function in WordPress uses the PHP mail() function behind the scenes, with a From: address set by WordPress or by each plugin. These sends therefore count against your hosting plan quota, and you can monitor them from the OVHcloud Control Panel.

For a fixed, authenticated sender on every email from your site, install an SMTP plugin that replaces wp_mail() with an authenticated SMTP connection to your OVHcloud mail server.

3.2 Configuring WP Mail SMTP

WP Mail SMTP is the most widely used plugin for this configuration.

Installation:

  1. In your WordPress administration, go to Plugins > Add New Plugin.
  2. Search for WP Mail SMTP and click Install Now, then Activate.

Configuration:

  1. Go to WP Mail SMTP > Settings in the administration menu.
  2. In the From section, fill in the following fields:
FieldValue
From Emailcontact@mydomain.ovh (address belonging to your domain)
From NameDisplay name for your site (for example My Website)
  1. In the Mailer section, select Other SMTP.
  2. Fill in the SMTP settings:
FieldValue
SMTP Hostsmtp.mail.ovh.net
EncryptionSSL/TLS
SMTP Port465
AuthenticationEnabled
SMTP Usernamecontact@mydomain.ovh
SMTP PasswordPassword of your OVHcloud email account
  1. Click Save Settings.
  2. In the Tools tab, use Email Test to check the configuration.
Tip

Enable the Force From Email option so that all outgoing emails use the configured address, even if a third-party plugin tries to use another one.

3.3 Alternative: FluentSMTP

FluentSMTP is a lightweight, free alternative. Your email account's sending quota applies in the same way.

Installation:

  1. In your WordPress administration, go to Plugins > Add New Plugin.
  2. Search for FluentSMTP and click Install Now, then Activate.

Configuration:

  1. Go to FluentSMTP > Settings.
  2. Click Add Connection and select Other SMTP.
  3. Fill in the same settings as for WP Mail SMTP:
FieldValue
Hostsmtp.mail.ovh.net
Port465
EncryptionSSL/TLS
AuthenticationYes
Usernamecontact@mydomain.ovh
PasswordPassword of your OVHcloud email account
From Emailcontact@mydomain.ovh
  1. Click Save Connection, then send a test email.

3.4 Other CMSs (Drupal, Joomla, PrestaShop)

The principle is the same for any CMS or framework: replace the native sending function with a module or an authenticated SMTP configuration.

CMSRecommended module
DrupalSMTP Authentication Support
JoomlaNative configuration: System > Global Configuration > Server tab > Mail Settings section
PrestaShopAdvanced Parameters > E-mail — choose Set my own SMTP parameters

In all cases, the SMTP settings are the same: server smtp.mail.ovh.net, port 465 (SSL/TLS) or 587 (STARTTLS), with authentication using the full email address and its password.

Go further

Monitoring and managing automated emails in your web hosting plan

Technical specifications of web hosting plans

How to improve email security with an SPF record

How to improve email security with a DKIM record

How to improve email security with a DMARC record

For specialised services (SEO, development, etc.), contact the OVHcloud partners.

If you would like assistance using and configuring your OVHcloud solutions, please take a look at our support offers.

Join our community of users.

Was this page helpful?