---
title: "Sending emails via web-server"
canonical_url: "https://www.speedzone.fi/tuki/en/kb/sending-emails-via-web-server/"
post_type: "ht_kb"
published: "2023-08-16T12:26:00+00:00"
modified: "2025-10-14T13:38:54+00:00"
language: "en"
author: "silver"
taxonomies:
  ht_kb_category:
    - name: "Web Hosting Services"
      url: "https://www.speedzone.fi/tuki/en/kb-categories/web-hosting-services/"
    - name: "E-mail"
      url: "https://www.speedzone.fi/tuki/en/kb-categories/e-mail-en/"
    - name: "Technical"
      url: "https://www.speedzone.fi/tuki/en/kb-categories/technical-en/"
    - name: "WordPress"
      url: "https://www.speedzone.fi/tuki/en/kb-categories/wordpress-en/"
  ht_kb_tag:
    - name: "smtp"
      url: "https://www.speedzone.fi/tuki/en/kb-tags/smtp-en/"
---

# Sending emails via web-server

## General

Sending emails via web-server is completely possible in Zone and if you are hosting your website on Zone virtual server and you would like to send emails out from your website, please note, that **ports 25, 1025, 1026, 465 and 587 are closed**. Hence you can not use smtp.zone.eu server or any other server that is using the mentioned ports.

In order to send emails from your website, `localhost` has to be assigned as SMTP host name and port `25` should be used. Authentication or secure connection (SSL/TLS) is not required. Those values should be assigned as *false* or *none*.

### PHP

Here’s an example of PHP script’s settings:

```
$mail->Mailer = "smtp";
$mail->Host = "localhost";
$mail->Port = "25";
$mail->SMTPSecure = 'none';
$mail->SMTPAutoTLS = false;
$mail->SMTPAuth = false;
```

 Useful tip! Many external mail service providers like Sendgrid and Mailgun support **port 2525** to send email out. This port is not closed and can be used freely.

### Laravel

The Laravel setup looks like this:

```
MAIL_MAILER=smtp
MAIL_HOST=localhost
MAIL_PORT=25
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS="info@yourdomain.com"
MAIL_FROM_NAME="Senders name"
```

The configuration in the `./config/mail.php` file looks like this:

```
'mailers' => [
    'smtp' => [
    'transport' => 'smtp',
    'url' => env('MAIL_URL'),
    'host' => env('MAIL_HOST', '127.0.0.1'),
    'port' => env('MAIL_PORT', 2525),
    'encryption' => env('MAIL_ENCRYPTION', 'tls'),
    'username' => env('MAIL_USERNAME'),
    'password' => env('MAIL_PASSWORD'),
    'timeout' => null,
    'local_domain' => env('MAIL_EHLO_DOMAIN', parse_url(env('APP_URL', 'http://localhost'), PHP_URL_HOST)),
    'verify_peer' => false,
    ],
    ...
]
```

### WordPress – WP Mail SMTP plugin

Setting up the WP Mail SMTP plugin to send emails via `localhost` and port `25`:

### [![](https://www.speedzone.fi/static/sites/5/localhost-1024x538.png)](https://www.speedzone.fi/tuki/en/kb/sending-emails-via-web-server/localhost/)

## Email limitations

You are allowed to send out one email every five seconds. If you exceed this limit, an automatic restriction will be applied on sending emails via webserver. To remove this restriction, please contact our customer support at <tuki@speedzone.fi>.

## SPF

When sending emails via web-server, please make sure that your domain’s SPF record allows it. Otherwise the emails will be marked as spam or won’t be delivered at all.

In case your domain is using only Zone email services, the SPF record should look like this:

```
v=spf1 a mx include:_spf.zone.eu -all
```

If your website is hosted with us, but you are using email services elsewhere, the SPF record should be modified accordingly. Adding `include:_spf.zone.eu` to your domain’s SPF record is sufficient. Here’s an example:

```
v=spf1 ip4:123.4.5.6 include:_spf.zone.eu -all
```

 Useful tip! You can find instructions on how to add and manage an SPF record [here](https://www.speedzone.fi/tuki/en/kb/spf-record/).

## DKIM

In order to add authenticity to email that are sent from your webserver, you can use **[DKIM](https://www.speedzone.fi/tuki/en/kb/dkim/) signature**. DKIM will add a cryptographic signature to the email, so that the receiving end can be sure that the email was sent out properly and it has not been forged.

DKIM signature is available in our our packages.

You activate DKIM, in “My Zone” and choose `Web hosting`-&gt;`Email`.

## Changing PHP sendmail\_from

By default, the email form your web server are sent out from noreply address – for example `noreply@example.com`. This can be changed with PHP [mail()](http://ee1.php.net/manual/en/function.mail.php) function’s fifth parameter -f.

To change the default noreply address, log in to My Zone and choose `Web hosting`-&gt;`Webserver`-&gt;`Main domain settings`-&gt;`Modify`–&gt;`PHP settings`.

[![Sending emails via web-server is completely possible in Zone and if you are hosting your website on Zone virtual server and you would like to send emails out from your website, please note, that ports 25, 1025, 1026, 465 and 587 are closed.](https://www.speedzone.fi/static/sites/5/php_settings-832x1024.png)](https://www.speedzone.fi/tuki/en/kb/sending-emails-via-web-server/php_settings/)

On the next page the sendmail\_from value must be changed. You **only** need to enter the e-mail address in the form of `address@example.com`.

[![](https://www.speedzone.fi/static/sites/5/php_settings1-1024x534.png)](https://www.speedzone.fi/tuki/en/kb/sending-emails-via-web-server/php_settings1/)

## Log of e-mails sent from web server

The log of emails from the web server can be seen in the My Zone via Web-hosting management under `Logs` -&gt; `Webserver e-mail`.

Detailed instructions on the logs can be found [here](https://www.speedzone.fi/tuki/en/kb/log-of-e-mails-sent-from-web-server-2/).

## Using an external SMTP server

 Attention! The given guide is only an example and Zone customer support does not provide help for setting up an external SMTP server for customer’s web application.

Prerequisites for using an external SMTP server:

- Web-hosting package Pro
- Dedicated IP address (comes with web-hosting Pro package, ask customer support to activate it)
- external SMTP server that supports TLS/SSL connection over port 587

In order to send a mail from the web server through an external server, the application must send the mail to the IP address allocated to the virtual server. Typical plugins for WordPress and other applications do not allow you to do this in the user interface, so you have to do the configuration directly on a per-file basis.

 Important information! Port 25 cannot be used on shared web-hosting, even if your virtual server has its own dedicated IP address. This restriction is in place to prevent the risk of uncontrolled spam, which Zone would be unable to monitor or block effectively. However, with a dedicated IP, you can use alternative SMTP ports or consider upgrading to a [managed cloudserver](https://www.zone.fi/en/managed-cloudserver/).

It must be taken into account that the webserver e-mail log visible in the My Zone management panel does not display the mails sent via an external server.

#### Example 1: [WP Mail SMTP by WPForms](https://et.wordpress.org/plugins/wp-mail-smtp/)

To send emails from the specific IP address, the following filter must be added into the functions.php file:

```
add_filter('wp_mail_smtp_custom_options',function($phpmailer){
  $phpmailer->SMTPOptions=[
    'socket'=>[
      'bindto' => '1.2.3.4:0'
    ]
  ];
  return $phpmailer;
});
```

where on the row of `'bindto' => '1.2.3.4:0'` replace `'1.2.3.4:0'` with a allocated dedicated IP address.

**NB!** The IP address is followed by `:0`.

Example of a plugin configuration:

[![Sending emails via web-server: Example 1: WP Mail SMTP by WPForms](https://www.speedzone.fi/static/sites/5/WP-dedicated-IP-SMTP-setup.png)](https://www.speedzone.fi/tuki/en/kb/sending-emails-via-web-server/wp-dedicated-ip-smtp-setup/)

#### Example 2: [Nodemailer](https://nodemailer.com/)

In Nodemailer, you can set up dedicated IP address with the `localAddress` value. Gmaili SMTP as an example:

```
nodemailer.createTransport({
    host: 'smtp.gmail.com',
    port: 465,
    secure: true,
    auth: {
        user: 'username@gmail.com',
        pass: 'password'
    },
    localAddress: '1.2.3.4'
});
```

where on the row of `localAddress: '1.2.3.4'` replace `'1.2.3.4'` with a allocated dedicated IP address.

### Example 3: [Laravel](https://laravel.com/)

Laravel `.env` file example:

```
MAIL_MAILER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=username@gmail.com
MAIL_PASSWORD=password
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS="username@gmail.com"
MAIL_FROM_NAME="Sender name"
```

An example of `./config/mail.php` configuration file:

```
'mailers' => [
    'smtp' => [
    'transport' => 'smtp',
    'host' => env('MAIL_HOST', 'smtp.gmail.com'),
    'port' => env('MAIL_PORT', 587),
    'encryption' => env('MAIL_ENCRYPTION', 'tls'),
    'username' => env('MAIL_USERNAME'),
    'password' => env('MAIL_PASSWORD'),
    'timeout' => null,
    'local_domain' => env('MAIL_EHLO_DOMAIN'),
    'source_ip' => '1.2.3.4',
    ],
    ...
],
```

where on the row of `'source_ip' => '1.2.3.4',` replace `'1.2.3.4'` with a allocated dedicated IP address.
