I moved my Wordpress websites from VestaCP to HestiaCP 1.1.0.
The problem is that now Wordpress doesn’t send emails. However, I can send emails with PHP using the terminal.
I used PHP to test if the server could send emails:
mail ('[email protected]', "Test Postfix", "Test mail from postfix");
Both old (VestaCP) and new (HestiaCP) servers can send emails successfully but in the server with HestiaCP emails go to spam folder of gmail. This might be why Wordpress doesn’t even send them.
Why the same PHP script in VestaCP sends email successfully and with HestiaCP they go to the Spam Folder?
Why Wordpress doesn’t even send emails?
Any tips on what should I look at? Thanks!
Use mailtester : https://www.mail-tester.com/ to see what is wrong with your email.
Also keep in mind that ip reputation is extremely important, if your new server ip was previously used for spam there is nothing you can do from the Hestia side.
Post here the sendmail path from your php-fpm config
grep sendmail_path /etc/php/7.X/fpm/pool.d/DOMAIN.TLD.conf
I’m going to try that out.
Thanks for the fast reply. You guys are the best.
The mail-tester.com gave a lot of important information. I’ll probably require an entire day to digest it all.
Old VestaCP server (Time4VPS account): 2.9/10
New HestiaCP server (Hetzner account): 1.8/10
There’s a lot to improve. I think that the main problem might be the DNS entries since I use the FQDN from my Hetzner account.
I’m using static.184.108.40.206.clients.your-server.de (220.127.116.11 part is an example, not really my IP) as FQDN in HestiaCP since that’s what is shown in my Hetzner account. I don’t know if that’s a good idea. I never understood FQDN very well…
It’s probably better to setup my own DNS server with a local only FQDN (for example vps.local) and add SPF entry to it.
What do you think?
Thanks for the suggestion.
My “trouble” with FQDN is that I’ve different domains in my server, can I choose any of them to use as FQDN?
Can I use vps.domain1.com as FQDN? I already use Cloudflare.
Sure, just use vps.domain.tld.
I still can’t send emails with wordpress using php in the HestiaCP installation. I’ll try to get Wordpress to use the smtp server with the Post SMTP plugin, which rmjtechnologies suggested.
I tried in the old server with VestaCP and it works only if dovecot is enabled, otherwise I’ll get a:
435 Unable to authenticate at present
However, I didn’t install dovecot in HestiaCP, I have a minimal installation with only:
What’s the best method to add dovecot to HestiaCP after it was already installed?
You could try to get the related parts for dovecot installation out of the installer, but currently there is no easy way to add a missing part manualy.
Depends on how you want to solve it, maybe a fresh installation of hestia could be the faster way.
I’ll try a fresh installation of HestiaCP.
Just another thing, is this Exim queue size (over 1.000) normal? It seems a lot of activity right there. I imagine that they are emails that Wordpress is trying to send but fail and get in queue instead, right?
Thanks, I deleted all the mails frozen in the queue. I think that all those mails were from cron jobs that failed when I was messing with the hostnames and DNS settings in Cloudflare.
I’m going to reinstall HestiaCP. I like minimal installations to spare CPU and RAM.
Can I avoid installing these packages without problems?
Vsftpd (I don’t use FTP, only SFTP/SSH with FileZilla)
Bind (I use DNS of Cloudflare)
ClamAV and SpamAssassin use too much resources, can I avoid these two? I only use exim to redirect emails to my gmail accounts. Also if Wordpress still can’t manage to send emails via PHP I’ll use the SMTP server to do it.
Thanks and sorry for asking so many questions. Hopefully your answers will also help other newbies.
Yes, you can avoid to install vsftpd and bind - also you could disable/exclude clamav and spamassassin if needed for installation.
I reread Lupu’s answer and realized that I missed an important tip. So I went to investigate the /etc/php/7.3/apache2/php.ini
Meaning that the sendmail path wasn’t configured.
So I went to my old VestaCP configuration and found this:
sendmail_path = /usr/sbin/sendmail -t -i
So I added this line to my php.ini in HestiaCP.
I also installed sendmail, somehow it wasn’t installed…
Yet, sendmail replaced exim…
I tried to reinstall exim, but it seems that I have to choose between exim and sendmail.
[email protected]:~# apt install exim4
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
liblockfile1 lockfile-progs procmail sendmail-base sensible-mda
Use 'apt autoremove' to remove them.
The following additional packages will be installed:
exim4-base exim4-config exim4-daemon-light libevent-2.1-6 libgnutls-dane0 libunbound8
exim4-doc-html | exim4-doc-info eximon4 mail-reader spf-tools-perl swaks dns-root-data
The following packages will be REMOVED:
The following NEW packages will be installed:
exim4 exim4-base exim4-config exim4-daemon-light libevent-2.1-6 libgnutls-dane0 libunbound8
Messing around with configs I now get 9/10 in mail-tester.com and Wordpress still doesn’t send emails…
Anyway, I forgot to mention that the old VestaCP (where Wordpress can send emails) was installed in CentOS 7, so packages are different. In CentOS it seems we can have both, sendmail and exim working.
Anyway, I’ll install a fresh new HestiaCP, it makes more sense because I installed the beta version then upgraded to stable and I don’t fully trust the stability of upgrades to beta versions.
I’ll report back if I get this working (Wordpress sending emails).
So I read a tutorial from https://easyengine.io/tutorials/php/test-email-sending/ and the author suggested to use postfix instead of sendmail…
It’s better to use postfix. It’s sendmail compatible and is more powerful.
You can try it if you ever run into issues with sendmail.
So I tried…
[email protected]:~# apt install postfix
In Post SMTP plugin I finally got the message I wanted to see:
Your message was delivered (0 ms) to the SMTP server! Congratulations
Now I don’t have exim installed, which I need since I use the HestiaCP GUI to configure it to redirect emails to my Gmail accounts.
Nonetheless, I’ll try a fresh new HestiaCP installation and see if I can get sendmail and exim working together…
I’ll report back.
Interesting journey you had there still HestiaCP should work fine out of the box, not need to install sendmail or postfix, a clean install should take no longer then 15 minutes.
- 10/10 on Mailtester is no problem for Hestiacp, we see that all the time
- check if wordpress is not configured with a manual smtp config, i suggest you test on a vanilla wordpress and continue from there.
- make sure dns and reverse dns are correctly configured for the server ip
This is super important if you want your emails to stand a chance to land in inboxes! The SMTP server could be a different server than Hestia with a different domain if you need to. WordPress default config is to sent email via php. You need to change that.
But Hestia mail setup can pass a 10/10 on mailtester out of the box. Just make sure you have RDNS set correctly (consult with your VPS provider about that) and check that the VPS IP is not blacklisted. Last but not least, don’t forget about SPF and DKIM.
Reinstalled HestiaCP and now all is working great. Wordpress can now send emails via PHP and SMTP.
Thanks for all the help.
Glad to hear this @LITUATUI
Note: you should keep an eye on exim queue size, if it is still rising you might want to check for weak email passwords or a vulnerable WP plugin.
That’s solved. There were a lot of emails in queue because I messed with hostnames and cron jobs. When cron jobs failed hestiacp tried to send warning mails unsuccessfully…
After reinstalling HestiaCP and adding DKIM records to Cloudflare DNS I now have a 10/10 in mail-tester.com
I’m now just trying to figure out a way to protect/hide the Roundcube Webmail login page, I don’t like to have admin login pages available to everyone.
I have the login page of HestiaCP in a different port and also only available to my IP, I would like to be able to do the same thing for Roundcube.
Stupid me, I already use Cloudflare firewall to protect the wordpress admin login, yet I forgot that I could do the same for roundcube. Thanks!