A PHP script on your website can send emails in two ways: through an authenticated SMTP connection to a real email address of your domain, or with PHP's mail() function, which must first be enabled in the Apanel console.
The authenticated SMTP connection is clearly preferable: it ensures better deliverability of your messages. The server, port and encryption to enter in your script or sending extension are described in the article Email settings for all email clients (IMAP, POP, SMTP), with the full email address and its password as credentials.
In short: prefer an authenticated SMTP connection with an email address of your domain. For mail(), enable Enable PHP mail function in PHP configuration (Website section), then click Save.
Prerequisites
- A website hosted at SwissCenter.
- Access to the domain's Apanel console, to enable the
mail() function.
How do I enable the mail() function?
- Log in to your Apanel console.
- Open Hosting management for the relevant domain.
- In the Website section, click PHP configuration.
- Under Advance configuration, enable Enable PHP mail function.
- Click Save.

How do I send an email with mail()?
Here is a simple example for sending an email from a PHP script:
<?php
$to = 'nobody@example.com';
$subject = 'Le Sujet';
$message = 'Bonjour';
$headers = 'From: webmaster@example.com' . "\r\n" .
'Reply-To: webmaster@example.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
?>
Are emails sent with mail() filtered?
Once the function is enabled and the script is set up, emails sent with the mail() function from your site pass through a filtering gateway that rejects the most common spam. This prevents your site from becoming a source of spam in the event of a hack or the exploitation of an unprotected form.
In general, it is strongly advised to protect every form that triggers an email (contact forms, etc.) against spam robots, for example with a "captcha".
Troubleshooting
- Emails sent by the site land in spam or do not arrive: switch to authenticated SMTP sending. The article Improve the deliverability of emails sent by your website explains why the
mail() function is less reliable.
- Sending was blocked after a form was abused: protect the form (captcha), then contact our support to have sending unblocked.
Going further