Hi @slamkajs ,
Hope you are doing good. I’m not clear exactly what you are trying to achieve here, but one thing I would like to point out is that modifying plugin code carries some risk, and it’s essential to be cautious and well-informed when making such changes. Additionally, maintaining custom code may require ongoing effort to ensure compatibility with plugin updates and other system changes.
If you only want to track the emails, you can simply use wp_mail_succeeded hook.
Check the code reference.
Best of luck with your discovery.
Thanks!
im completely aware of the dangers involved in modifying the code. Even if the changes are valid, updating the plugin erases the change.
The goal I am trying to accomplish does not involve monitoring if an email was sent, I have an external application which monitors incoming mall communications via Mailgun. The main issue I have is I want to be able to specify the FROM address. The Sendinblue engine already allows for the overwriting of the FROM email address, but Mailgun engine does not.
@slamkajs thanks for the details. Can you share the code which you are using to overwrite the From address? That might help me to understand what you are looking for.
Thanks!
Here is the gist of my email generation.
// SET EMAILS
$from_email = $_POST["email"];
$to_email = $_POST["toEmail"];
$subject = "Contact Request from ...";
$headers = ["From: " . $_POST["firstName"] . " " . $_POST["lastName"] . " <" . $from_email . ">"];
$sent = wp_mail($to_email, $subject, "body content for email", $headers);
I can see when debugging through the Mailgun engine that my header’s FROM email address and name are found. The issue is Mailgun’s engine does not give a condition to keep or overwrite the FROM email address. It implements the POST SMTP Mailer’s FROM email address every time. I am looking for it to check if a FROM email address already exists and if it does then it should NOT use the plugin’s FROM email address.
Thanks @slamkajs for providing the details. We may need to test this case and will see if we can add a patch for it. It might take a few weeks (if we deiced to update this in core). Anyways, will keep you updated with the progress.
Till then you can manage it on your end as you have already discovered.
Thanks!