Set virtual server domains to send email (from forms) to external email hosting

24 posts / 0 new
Last post
#1 Mon, 10/07/2019 - 16:27
Gianni

Set virtual server domains to send email (from forms) to external email hosting

Hello to all, ... I have configured two virtual servers on virtualmin that work well but I would like to use mail from an external hosting to send emails from the forms of the two sites.

I activated the user "info@mydomain.com" on email hosting and point external dns to it and works perfectly, but the emails sent by the forms of the two sites in virtualmin stay in home of the two default users.

I also tried to disable the mail services for the two virtual servers (Virtualmin - Edit Virtual Server - Enabled features: unchecked "Mail for domain enabled?" And also antivirus and antispam) but nothing.

Is there a tutorial or guide I can follow for this specific problem ? I really have been looking for a solution to my problem for a very long time.... : (( Thanks to anyone who can help me ... Gianni

Tue, 10/08/2019 - 14:17
Dibs

I think you need to get the PHP (perhaps) forms to use SMTP auth (or similar) to login to the external mail hosting to send the emails. https://help.dreamhost.com/hc/en-us/articles/216140597-How-do-I-send-PHP... might get you where you need to be.

HIH

Dibs

Wed, 10/09/2019 - 05:31
Gianni

Hi Dibs, ... my sites are on wordpress, so I could use a plugin to send, but I think there is an alternative solution configuring only Webmin / virtualmin. I have seen that webmin uses Postfix and Dovecot to create its own email server, but possibly I would like to disable them because my vps only has 1Gb ram. I read that by deactivating the mail server for a domain, emails are sent to the correct address by default, instead of putting them in the user's home, but unfortunately this does not happen. Thanks for your help Dibs, I really appreciate it ... Hi Gianni

Wed, 10/09/2019 - 05:44
Dibs

Hi Gianni, If you disable Postfix\Dovecot at the VPS level, then I wouldn't think your VPS would respond to any traffic on Port 25. But if you have other domains (& Virtual Servers) on the VPS - then that might not be doable. So you would want it to receive mail for other domains but not those 2 (and also not send for those 2). Does the following help you at all?

https://rimuhosting.com/support/settingupemail.jsp?mta=&t=local#local

Dibs

Wed, 10/09/2019 - 12:26 (Reply to #4)
Gianni

... make it clearer:

  • I created my vps (1Gb ram) with webmin and 3 simple virtual sites in Wordpress, each with a contact form.
  • all e-mails of the 3 domains, incoming and outgoing, reside on an external hosting.

Is possible to configure webmin to send contact forms without creating your own mail server (and without WP plugin)?

thank you very much also for the link, it does not suit my needs but it is still very interesting. : )

Wed, 10/09/2019 - 13:58 (Reply to #5)
Dibs

Hi Gianni,

With no mail server - meaning no forwarding or relaying, I don't see how PHP could send the mail. You would need PHP, either coded yourself or a WP plugin to login to your external mailserver and send the emails from the form. Webmin & Usermin to my understanding (could be wrong) are just GUI's to not have to alter the various config files manually.

HIH

Dibs

Wed, 10/09/2019 - 15:43 (Reply to #6)
Gianni

Yes, you're right, but I don't think that Webmin is just a ui, it has a "api" and several basic modules written in perl. It could easily use the Email :: Send function in one of its basic modules or one of the other 936 ways to send an email in Perl. But after so much reading, I also believe that it is necessary to keep at least Postfix to be able to connect to the external SMTP server. And now the question becomes: how to set Postfix to use a different SMTP for each virtual domain? Thanks Dibs, for clarifying my ideas ... : )

Wed, 10/09/2019 - 16:18 (Reply to #7)
Dibs

You may well be right - Webmin may have an API, I haven't delved into it in that level of detail. For me it's like Virtualmin - an administrative tool (UI was probably not the best\correct description). To my mind, they only go so far - for more advanced\serious stuff, I've ended up manually altering the relevant config files to get what I want.

Take a post - which I think is virtually identical to yours - If you look at the following post https://www.virtualmin.com/node/67429 - the poster is referred to changing the config under the "hood". Or that's my take on it.

If Postfix is the MTA, that will need the configuration. You could use a lightweight equivalent that isn't a full blown MTA. I think there are some about. Or as you pointed out, Email::Sender the successor to Email::Send but you'd have to alter the code in the forms to do that. Or maybe write a module\function that did it and the WP forms\sites didn't realise there wasn't a full blown MTA underneath (might have cons as well as pros).

ATB

Dibs

Thu, 10/10/2019 - 16:30 (Reply to #8)
Gianni

Yes, I fully agree with you, after a lot of research I have seen many posts recommending to manually change the postfix configuration. I can't exclude that Webmin allows to configure STMP "per domain" but for now I haven't found anything about it. I think I won't look for a postfix equivalent, and I won't write a custom module. As soon as possible will setup instead Postfix manually as you suggested... : )

Wed, 10/09/2019 - 06:32
Jfro

IF switching of email only for domain / that virtualservers, and postfix still running on the hostname / server, then most mailforms use that host/username mail in virtualmin server mailfunctions / postfix if so.

ONLY PHP SMTP mailforms , or maybe more special own postfix config ( mappings and so i believe) but then still running and using resources from your server by postfix.

NOT RUNNING POSTFIX or other mailsystem on that box then you have to config everything for external MAIL systems to still get warning / errrors and all the virtualmin / webmin / firewall notifications and so on.

IF USING FORWARDS for example then with aliases hmm then also dkim/dmarc/spf would become problem with bounces a guess. AND YOU SERVER IP goes here in short time :(

http://www.backscatterer.org/index.php?target=test

Wed, 10/09/2019 - 14:16 (Reply to #10)
Gianni

Hi Jfro, thanks for your contribution ...

So if I understand correctly, there are three solutions: 1) use WP plugin (php smtp server) and disable postfix and Dovecot 2) use postfix as SMTP to send forms and disable Dovecot 3) use postfix configured to send with external SMTP

While the first two solutions use many resources to send through my VPS, the third solution connects external hosting to send, I think using fewer resources ... and also should not be problems for DKIM and DMark. Correct?

Tonight I was able to configure Virtualmin for solution 3, but it seems impossible to use a different email hosting for each domain. I have in fact configured Postfix from Webmin - Server - Postfix: "Send outgoing mail via host" but ALL domains use this SMTP, while it is important that each domain uses a different SMTP ...

What do you think about it?

Wed, 10/09/2019 - 14:26 (Reply to #11)
Dibs

When you do it it Webmin - I think that's doing it at the global level. Used for those kinds of situations where the ISP blocks port 25 and requires you to relay all mail thru their mailservers. Less applicable to a VPS & Data centre environment but an applicable case.

You want to do it on a per domain basis - if I understand you correctly. That's going to require altering Postfix files manually (I think). The following link should hopefully help - https://serverfault.com/questions/565573/postfix-smtp-authentication-per...

HIH

Dibs

Thu, 10/10/2019 - 17:10 (Reply to #12)
Gianni

Perfect Dibs, I think that "per domains basis" is what i'm searching !!! I'll try tomorrow and I'll let you know ...

Wed, 10/09/2019 - 18:00 (Reply to #13)
Jfro

Can't help sorry. Am no programmer and not using WP Also using mself only Postfix with virtualmin then the mailserver host is also default for everydomain on our box , so mx points to mail.hostname.

Using EXIM on other systems but in the same way.

Simple because less problems in such configs, easier to take care of, (If custommer domains with real own IP's then maybe) SNI POSTFIX hmm , it wasn't made for.

Thu, 10/10/2019 - 17:23 (Reply to #14)
Gianni

No problem, no one knows all the computer science.

I chose this configuration for two reasons, 1) less RAM, 2) so as not to reveal the ip of the webserver (if the mail server resides with the webserver, the MX record reveals the webserver ip). If instead I hide the webserver behind Cloudflare and the mail server is managed externally, the ip of the webserver is masked (a little bit more secure)...

Wed, 10/09/2019 - 06:46
Jfro

OYEA Wordpress and more sites 1GB is way to low.

Wed, 10/09/2019 - 14:30 (Reply to #16)
Gianni

Yes you are right. But on the VPS there are only three very small WP sites and I have a really small budget. I have also disabled statistics, antivirus and antispam and I also hope Dovecot. On WP I've activate the cache and use Cloudflare, it doesn't go so bad ... : ))

Wed, 10/09/2019 - 14:38 (Reply to #17)
Dibs

This link https://forums.zimbra.org/viewtopic.php?t=3859 has probably better details\instructions. You just need to "adjust" file locations to ignore the zimbra locations and use the ones relevant to your OS.

Budget - manually adjusting the files should not cost you anything. ;)

On my VPS which also has 1GB, I have disabled AV, but it runs everything else and has 2 static WP sites and 1 static HTML\PHP site and since I spent some more time on it - it runs very well. Just required some reading, learning and altering config files. Admittedly, I'm not new to Linux (far from an expert).

Wed, 10/09/2019 - 16:59 (Reply to #18)
Gianni

: ) useful link !!!

... But I would first try to look if I can configure webmin in "per domain" mode (because I would not have to manually reconfigure it when upgrading). If I can't find anything I try the manual configuration you suggested ...

Thanks for the very interesting discussion Dibs. : )

Thu, 10/10/2019 - 10:08
Dibs

Gianni - let us know how you get on? The final solution (workable) might be of interest to others at some point.

Cheers

Dibs

Thu, 10/10/2019 - 12:58 (Reply to #20)
Gianni

Yes sure! Unfortunately my life is a bit complicated and sometimes I have to turn off my PC.,, As soon as I have time I'll try the configuration suggested, if it works I definitely post it here... : )

Thu, 10/10/2019 - 13:02
anahata
anahata's picture

You might be able to do this by removing postfix and installing a minimal SMTP sender like nullmailer or dma that doesn't need much memory. Configure that to send via authenticated SMTP to the other server that can relay mail for the domains. Those programs emulate sendmail, and PHP's mail() function should be able to connect to them via a local socket or localhost.

Anahata www.treewind.co.uk West Yorkshire, UK

Thu, 10/10/2019 - 13:20 (Reply to #22)
Dibs

Anahata - Wow - what are the chances of randomly "bumping" into someone on the internet that lives 10 miles down the road. LOL

Fri, 10/11/2019 - 07:32 (Reply to #24)
Gianni

Hi Anahata, welcome in this topic. Thanks for the advice, unfortunately the nullmailer or dma software are not part of the modules managed by Webmin. I should therefore setup and manage them separately and it is not very practical ...

Topic locked