# Unable tos end email with jailkit enabled

**URL:** <https://forum.virtualmin.com/t/unable-tos-end-email-with-jailkit-enabled/133455>\
**Category:** Virtualmin\
**Created:** [May 18, 2025, 11:58am UTC](https://forum.virtualmin.com/t/unable-tos-end-email-with-jailkit-enabled/133455 "2025-05-18T11:58:10Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![hescominsoon](https://cdn.forum.virtualmin.com/user_avatar/forum.virtualmin.com/hescominsoon/32/2358_2.png) [@hescominsoon](https://forum.virtualmin.com/u/hescominsoon)\
**Post date:** [May 18, 2025, 11:58am UTC](https://forum.virtualmin.com/t/unable-tos-end-email-with-jailkit-enabled/133455/1 "2025-05-18T11:58:11Z")

</div>

never mind i’ll work around it

---

<div class="post-metadata">

**Author:** ![jimr1](https://cdn.forum.virtualmin.com/user_avatar/forum.virtualmin.com/jimr1/32/14173_2.png) [@jimr1](https://forum.virtualmin.com/u/jimr1)\
**Post date:** [May 18, 2025, 3:13pm UTC](https://forum.virtualmin.com/t/unable-tos-end-email-with-jailkit-enabled/133455/2 "2025-05-18T15:13:47Z")

</div>

If your using jailkit you need to add everything to each jail, such as postfix, dovecot etc. Just out of interest why are using jailkit ?

---

<div class="post-metadata">

**Author:** ![Joe](https://cdn.forum.virtualmin.com/user_avatar/forum.virtualmin.com/joe/32/9_2.png) [@Joe](https://forum.virtualmin.com/u/Joe)\
**Post date:** [May 18, 2025, 5:36pm UTC](https://forum.virtualmin.com/t/unable-tos-end-email-with-jailkit-enabled/133455/3 "2025-05-18T17:36:15Z")

</div>

You need to give us the actual error. It depends on how you’re sending mail, but most of the time something doesn’t work in the jail is just because you didn’t put the necessary software in the jail. A jailed user cannot run anything you didn’t explicitly give them access to, that’s the point of the jail.

---

<div class="post-metadata">

**Author:** ![Joe](https://cdn.forum.virtualmin.com/user_avatar/forum.virtualmin.com/joe/32/9_2.png) [@Joe](https://forum.virtualmin.com/u/Joe)\
**Post date:** [May 18, 2025, 5:37pm UTC](https://forum.virtualmin.com/t/unable-tos-end-email-with-jailkit-enabled/133455/4 "2025-05-18T17:37:30Z")

</div>

> [@jimr1](#):
>
> you need to add everything to each jail, such as postfix, dovecot etc.

Oh no!

You definitely do not want/need to do that, and it would be dangerous to do that, as both of those include suexec binaries.

---

<div class="post-metadata">

**Author:** ![hescominsoon](https://cdn.forum.virtualmin.com/user_avatar/forum.virtualmin.com/hescominsoon/32/2358_2.png) [@hescominsoon](https://forum.virtualmin.com/u/hescominsoon)\
**Post date:** [May 18, 2025, 8:58pm UTC](https://forum.virtualmin.com/t/unable-tos-end-email-with-jailkit-enabled/133455/5 "2025-05-18T20:58:00Z")

</div>

never mind i’ll work around it

---

<div class="post-metadata">

**Author:** ![hescominsoon](https://cdn.forum.virtualmin.com/user_avatar/forum.virtualmin.com/hescominsoon/32/2358_2.png) [@hescominsoon](https://forum.virtualmin.com/u/hescominsoon)\
**Post date:** [May 18, 2025, 8:58pm UTC](https://forum.virtualmin.com/t/unable-tos-end-email-with-jailkit-enabled/133455/6 "2025-05-18T20:58:34Z")

</div>

jailkiot keeps one apache user form being able to infect another apache user.

---

<div class="post-metadata">

**Author:** ![Joe](https://cdn.forum.virtualmin.com/user_avatar/forum.virtualmin.com/joe/32/9_2.png) [@Joe](https://forum.virtualmin.com/u/Joe)\
**Post date:** [May 18, 2025, 9:06pm UTC](https://forum.virtualmin.com/t/unable-tos-end-email-with-jailkit-enabled/133455/7 "2025-05-18T21:06:05Z")

</div>

I have no idea. I’ve never heard of smtp2go.

You need to dig down into the logs and see what’s actually going on. “unable to instantiate mailsystem” is a meaningless error.

If it used to work with the jail enabled (are you _sure_?) then it seems like it must be a configuration issue. You should try using an IP address instead of a hostname to specify the SMTP server, if it’s sending via localhost, since making the hosts file work inside a jail is tricky. You may also want to add logging to your application to narrow down why it’s failing (i.e. check to be sure the hostname you’re trying to send to resolves, log what errors are returned when trying to connect, etc.).

---

<div class="post-metadata">

**Author:** ![Joe](https://cdn.forum.virtualmin.com/user_avatar/forum.virtualmin.com/joe/32/9_2.png) [@Joe](https://forum.virtualmin.com/u/Joe)\
**Post date:** [May 18, 2025, 9:11pm UTC](https://forum.virtualmin.com/t/unable-tos-end-email-with-jailkit-enabled/133455/8 "2025-05-18T21:11:14Z")

</div>

> [@hescominsoon](#):
>
> jailkiot keeps one apache user form being able to infect another apache user.

No, it doesn’t.

It keeps users from being able to _see_ other users on the system, and also limits which commands users can execute. It has nothing to do with Apache (Apache is not jailed), and your user code is never run by Apache in a properly configured system…the code is run by PHP-FPM which runs as the domain owner user and Apache proxies user requests to FPM. Apache is entirely independent of jailkit.

Jailkit is only marginally related to security. It may be able to limit the attack surface in the event a user account is compromise, if carefully deployed. On Debian/Ubuntu it can actually increase the risk of an exploit, as it does not use capabilities and instead has suid binaries (EL Jailkit packages use capabilities, instead, mostly removing that risk). At least that was true the last time I checked. But, it doesn’t really have anything to do with any system services.

To be clear, Apache cannot be exploited by users with or without jailkit. Users are not able to run code as the Apache user unless you have (against all of our advice and warnings) enabled `mod_php`, in which case Jailkit _really_ can’t save you because Apache is not jailed. All application code runs as the domain owner user.

---

<div class="post-metadata">

**Author:** ![hescominsoon](https://cdn.forum.virtualmin.com/user_avatar/forum.virtualmin.com/hescominsoon/32/2358_2.png) [@hescominsoon](https://forum.virtualmin.com/u/hescominsoon)\
**Post date:** [May 19, 2025, 8:46pm UTC](https://forum.virtualmin.com/t/unable-tos-end-email-with-jailkit-enabled/133455/9 "2025-05-19T20:46:44Z")

</div>

never mind i’ll work around it

---

<div class="post-metadata">

**Author:** ![Joe](https://cdn.forum.virtualmin.com/user_avatar/forum.virtualmin.com/joe/32/9_2.png) [@Joe](https://forum.virtualmin.com/u/Joe)\
**Post date:** [May 19, 2025, 9:18pm UTC](https://forum.virtualmin.com/t/unable-tos-end-email-with-jailkit-enabled/133455/10 "2025-05-19T21:18:47Z")

</div>

> [@hescominsoon](#):
>
> however smtp2go, and it’s competitors like malgun and others, intercept those mail calls and reroute them to their own infrastructure

They do not intercept mail. You are explicitly sending mail to them to be forwarded. If you’re not explicitly sending it to them, they can’t forward it.

> [@hescominsoon](#):
>
> so what would you suggest i add to the jail section to allow these communications from form plugins and the smtp plugins?

I don’t know. I still don’t see errors I can do anything with. What is in the PHP and web server logs when you try to send email?

---

<div class="post-metadata">

**Author:** ![hescominsoon](https://cdn.forum.virtualmin.com/user_avatar/forum.virtualmin.com/hescominsoon/32/2358_2.png) [@hescominsoon](https://forum.virtualmin.com/u/hescominsoon)\
**Post date:** [May 19, 2025, 9:34pm UTC](https://forum.virtualmin.com/t/unable-tos-end-email-with-jailkit-enabled/133455/13 "2025-05-19T21:34:04Z")

</div>

never mind i’ll work around it

---

<div class="post-metadata">

**Author:** ![jimmy06](https://cdn.forum.virtualmin.com/user_avatar/forum.virtualmin.com/jimmy06/32/20364_2.png) [@jimmy06](https://forum.virtualmin.com/u/jimmy06)\
**Post date:** [June 11, 2025, 10:06pm UTC](https://forum.virtualmin.com/t/unable-tos-end-email-with-jailkit-enabled/133455/14 "2025-06-11T22:06:39Z")

</div>

The issue seems to be that lots of scripts use the mail() module

Below is the output of a small script I wrote to test PHP mailing. Jails breaks password reset scripts for Wordpress and anything using the default mail() as sendmail is excluded from the jail.

I’d like to fix this the correct way so thought I’d update this thread.

As soon as I disable the jail this send fine

Starting PHP mail() diagnostics…  
✔ mail() function is available.  
sendmail\_path: /usr/sbin/sendmail -t -i  
SMTP: localhost  
SMTP Port: 25

Sending test email to: support@somedomain.tld  
✖ Mail failed to send.

```auto
<?php
echo "<pre>"; // Format output for readability

echo "Starting PHP mail() diagnostics...\n";

// Check if mail function exists
if (function_exists('mail')) {
    echo "✔ mail() function is available.\n";
} else {
    echo "✖ mail() function is NOT available.\n";
    exit("mail() function not available. Cannot proceed.\n");
}

// Display sendmail or SMTP configuration
$sendmailPath = ini_get('sendmail_path');
$smtp = ini_get('SMTP');
$smtpPort = ini_get('smtp_port');

echo "sendmail_path: " . ($sendmailPath ?: 'Not set') . "\n";
echo "SMTP: " . ($smtp ?: 'Not set') . "\n";
echo "SMTP Port: " . ($smtpPort ?: 'Not set') . "\n";

// Email parameters
$to = 'support@domainnamehere.tld;
$subject = 'PHP Mail Test';
$message = "This is a test email sent using PHP's mail() function.";
$headers = 'From: noreply@domainnamehere.tld' . "\r\n" .
           'Reply-To: noreply@domainnamehere.tld' . "\r\n" .
           'X-Mailer: PHP/' . phpversion();

// Attempt to send mail
echo "\nSending test email to: $to\n";
$success = mail($to, $subject, $message, $headers);

if ($success) {
    echo "✔ Mail sent successfully!\n";
} else {
    echo "✖ Mail failed to send.\n";
}

echo "</pre>";
?>

```

---

<div class="post-metadata">

**Author:** ![verne](https://cdn.forum.virtualmin.com/letter_avatar_proxy/v4/letter/v/dbc845/32.png) [@verne](https://forum.virtualmin.com/u/verne)\
**Post date:** [June 11, 2025, 10:14pm UTC](https://forum.virtualmin.com/t/unable-tos-end-email-with-jailkit-enabled/133455/15 "2025-06-11T22:14:20Z")

</div>

some say jailkit introduces more headaches and issues than solving problems 😃

any chance you don’t really need jailkit … just a random thought here.

---

<div class="post-metadata">

**Author:** ![Joe](https://cdn.forum.virtualmin.com/user_avatar/forum.virtualmin.com/joe/32/9_2.png) [@Joe](https://forum.virtualmin.com/u/Joe)\
**Post date:** [June 11, 2025, 10:22pm UTC](https://forum.virtualmin.com/t/unable-tos-end-email-with-jailkit-enabled/133455/16 "2025-06-11T22:22:58Z")

</div>

We already discussed why that fails.

> [@Joe](#):
>
> You should try using an IP address instead of a hostname to specify the SMTP server, if it’s sending via localhost, since making the hosts file work inside a jail is tricky.

You’re trying to send via `localhost`, and `localhost` is not resolving inside your jail. (You need some extra stuff, like `/etc/hosts` and some other stuff…`nsswitch.conf`, maybe? I don’t remember all the details…but, it’s simplest to just use `127.0.0.1`)

If you have further questions, please make a new topic, as you’re using different tools from the original discussion (though the problem remains the same).

---

<div class="post-metadata">

**Author:** ![jimmy06](https://cdn.forum.virtualmin.com/user_avatar/forum.virtualmin.com/jimmy06/32/20364_2.png) [@jimmy06](https://forum.virtualmin.com/u/jimmy06)\
**Post date:** [June 18, 2025, 8:20am UTC](https://forum.virtualmin.com/t/unable-tos-end-email-with-jailkit-enabled/133455/17 "2025-06-18T08:20:34Z")

</div>

using 127.0.0.1 does not work either @Joe

---

<div class="post-metadata">

**Author:** ![jimmy06](https://cdn.forum.virtualmin.com/user_avatar/forum.virtualmin.com/jimmy06/32/20364_2.png) [@jimmy06](https://forum.virtualmin.com/u/jimmy06)\
**Post date:** [June 18, 2025, 8:21am UTC](https://forum.virtualmin.com/t/unable-tos-end-email-with-jailkit-enabled/133455/18 "2025-06-18T08:21:04Z")

</div>

we have a few hundred websites that love to get compromised lol

---

<div class="post-metadata">

**Author:** ![jimmy06](https://cdn.forum.virtualmin.com/user_avatar/forum.virtualmin.com/jimmy06/32/20364_2.png) [@jimmy06](https://forum.virtualmin.com/u/jimmy06)\
**Post date:** [June 18, 2025, 10:10am UTC](https://forum.virtualmin.com/t/unable-tos-end-email-with-jailkit-enabled/133455/19 "2025-06-18T10:10:12Z")

</div>

Also, something doesnt add up, It works perfectly fine jailed and using FCGI, however in FCGI mode users lose access to the /home dir

This is the issue reported in 2023 [PHP email via FPM does not work, via FCGId it does work - Virtualmin - Virtualmin Community](https://forum.virtualmin.com/t/php-email-via-fpm-does-not-work-via-fcgid-it-does-work/121088)

I’m just looking for the correct solution to use I’d prefer jails but need basic functions to work.

---

<div class="post-metadata">

**Author:** ![Ilia](https://cdn.forum.virtualmin.com/user_avatar/forum.virtualmin.com/ilia/32/10185_2.png) [@Ilia](https://forum.virtualmin.com/u/Ilia)\
**Post date:** [June 18, 2025, 10:49am UTC](https://forum.virtualmin.com/t/unable-tos-end-email-with-jailkit-enabled/133455/20 "2025-06-18T10:49:25Z")

</div>

Which versions of Webmin and Virtualmin do you have installed?

---

<div class="post-metadata">

**Author:** ![Joe](https://cdn.forum.virtualmin.com/user_avatar/forum.virtualmin.com/joe/32/9_2.png) [@Joe](https://forum.virtualmin.com/u/Joe)\
**Post date:** [June 19, 2025, 2:16am UTC](https://forum.virtualmin.com/t/unable-tos-end-email-with-jailkit-enabled/133455/21 "2025-06-19T02:16:09Z")

</div>

We’ll need to see some actual logs, then, if it’s not the obvious problem of the address not resolving. The log should have some errors indicating what modules are missing or failing, which would give you clues about what’s missing from your jail.

---

<div class="post-metadata">

**Author:** ![jimmy06](https://cdn.forum.virtualmin.com/user_avatar/forum.virtualmin.com/jimmy06/32/20364_2.png) [@jimmy06](https://forum.virtualmin.com/u/jimmy06)\
**Post date:** [June 21, 2025, 8:47am UTC](https://forum.virtualmin.com/t/unable-tos-end-email-with-jailkit-enabled/133455/22 "2025-06-21T08:47:10Z")

</div>

I’m just going to test a clean install on a new VM to see if I can replicate it there.

If I can would you like access to it to see the issue?

 ![image](https://cdn.forum.virtualmin.com/uploads/default/original/3X/7/9/7901a611cf97deebed4291fdc0fcd57aa3eadd9e.png)

These are the versions we are currently running.

[Next page](https://forum.virtualmin.com/t/unable-tos-end-email-with-jailkit-enabled/133455.md?page=2)
