Closed iruzevic closed 8 months ago
Hi @iruzevic
The ENV configuration is actually for Laravel projects. WordPress needs either a plugin or a function for sending mails via SMTP.
It also looks like there is an issue with the standard setup for mails that we need to look into, so mails don't work for WordPress at the moment.
tnx for the comment. I'm looking forward to the fix, and it would be awesome if we could just configure this in the php.ini and send all the emails that way without the need for the additional WP plugin or something like that.
That's actually a WordPress issue and not a Herd problem. Herd uses a simple SMTP server for mails but WordPress uses a PHP function that no one should use because it's also used heavily for sending spam and so most email providers don't accept mails sent via PHP directly.
Sure, but we are talking about highjacking emails for local development before they get out in the world. Send an email, which gets routed back to the local service and displayed. I use Mailpit or MailHog, and they work perfectly by simply providing a sendmail_path
in my php.ini.
So, I don't see the issue with WP or spam here.
Herd is optimized for Laravel development and while it works for WordPress, we aim to keep it perfectly tailored to the Laravel framework. So I hope that we'll get that resolved but sending mail via PHP works fundamentally different than using an SMTP server and is not part of our roadmap at the moment.
Sending emails using SMTP in WordPress isn't too hard to configure. I've successfully used both Mailhog and Mailpit in the past. Here's how we configure SMTP in WordPlate: https://github.com/vinkla/wordplate/blob/bceda0061ca0ee6f038d997ab81847b4e409e145/public/themes/wordplate/functions.php#L98-L114
Tnx, configuring smtp for WP is easy. I just figured that this mail service could work the same way as Mailpit but out of the box without any configuration. It turns out this is not the case.
At the moment, it seems Herd Pro can't read emails sent from WordPress. I guessing it could be an easy fix since Herd already has an SMTP server set up and it registers the emails sent from WordPress.
Hi WordPress folks, I am mostly figuring out this stuff on the fly, but WordPress seems to be satisfied when adding this to the functions.php:
add_action('phpmailer_init', function ($mailer) {
$mailer->isSMTP();
$mailer->SMTPSecure = null;
$mailer->SMTPAuth = true;
$mailer->Host = '127.0.0.1';
$mailer->Port = 2525;
$mailer->Username = 'WordPress Test';
$mailer->Password = '';
return $mailer;
});
Unfortunately, mails don't show up in Herd nor are they saved to the internal database (we use sqlite and you could open it in something like TablePlus), so there seems to be a bug when parsing the email content and storing it in the database. We'll have a look and plan to release a fix version early next week.
I use Helo for local emails in WordPress (it's also written by Beyond Code) and I've written this WordPress plugin for it. Just install and activate, no configuration needed.
In theory my plugin should also work with Herd Pro as the settings are identical, but I don't have the Pro version of Herd to test it.
The problem is that HELO is written in Electron (JS) and Herd is written in Swift. Wordpress sends true
in a field of the email header that's actually reseved for HTML and while Javascript automatically converts the type of the value, Swift uses strict typing and fails because true
ist not a string.
This will be fixed in the next update, if you switch to the beta release channel, it's likely early next week.
We just released Herd 1.4.1 which fixes the error related to WordPress mails in Herd
Operating system version
macOs Sonoma 14.2.1
System architecture
ARM64 (M1, M2, etc)
Herd Version
1.4.0 (Build 20)
PHP Version
PHP 8.3
Bug description
Where do I place mailer constants for GUI when using WordPress setup?
I have created a .env file and added the constants to the root of my project, but the GUI is not recognizing it even after a hard restart."
Steps to reproduce
following the documentation
Relevant log output
No response