My Wordpress site isn't delivering emails using Postfix
The site is sending emails correctly from WooCommerce but any email that gets sent using Wordpress wp_mail() function is not sending the email I want (i.e. Contact Form 7 emails, User changed their password emails, etc.). I've changed the To address in Contact Form 7 to my own personal email and it delivers to my spam, but at least it's delivering. The email that it needs to be delivered to is my firstname.lastname@example.org and it's not even going to spam.
I'm not exactly sure where all I need to check but it seems that I may need to be looking more into Wordpress to fix this rather than Postfix. Every other email that is getting sent out using 3rd party plugins are delivering just fine.
I'm also not sure if this is related, but I am getting emails blocked every now and then and it says that the email sender is email@example.com.
Based on the fact that emails to your personal email are going to spam, but emails to
firstname.lastname@example.org are not delivering, there are a few possibilities.
The first and most common potential issue is that emails sent using WordPress' default PHP mail function are frequently flagged as spam, and depending on the mail server, they are either delivered to the spam inbox or rejected altogether. This is because the email appears to be coming from your domain, but is being sent from the email server. If you're using a third-party email server or if there is any discrepancy in the way your own mail server is configured, your emails will bounce before they're even filtered into the spam folder.
You can circumvent the spam-flagging issue by configuring WordPress to send emails via SMTP, which is the generally preferred method, but there are some configuration changes necessary - which brings us to the second possible cause. WordPress is not configured to use SMTP by default. Since it seems like other services on your Linode are sending emails appropriately, changing your WordPress settings may fix the issues you're seeing. This resource from WordPress has some more background information about PHP vs SMTP authentication and how to change your configurations to default to SMTP.
There is a caveat to this. After adjusting your WordPress settings, you may find that WooCommerce stops sending email. There is a setting in WooCommerce called "Force From Email" that overrides values set by other plugins; if you find that WooCommerce messages break after you change your WordPress settings, enable the "Force From Email" setting to ensure WooCommerce messages can send despite your adjustments to WordPress.
email@example.com: You may find this StackExchange post to be helpful. It likely has to do with how the mail command is being run by the mail client.
Thank you for the thorough reply. We are using Postfix and it wasn't set up by myself, so it's been hard to find the necessary configuration areas that might need changing. I've used MailGun before and was considering going that route again. I just wasn't sure if setting up Mailgun on my site would cause issues with Postfix still running.
I'm fairly new to mail servers so my understanding of the function of an MTA and SMTP isn't very extensive, but if I were to set up Mailgun and then use the WP Mail SMTP plugin would I need to change anything in my postfix configuration or would WooCommerce emails be the only thing that I would need to double check? And if I do end up going this route, should I just enable that setting in WooCommerce to make sure no emails get missed?
The site is currently live so there isn't much room for WooCommerce to stop delivering emails. The clients customer service team has just been using WP mail log to check for the emails that we know aren't being delivered correctly until we can get this sorted out.