Extension:ContactPage/SiteGround and SES

This page details a potentially common issue users may encounter when running this extension with the hosting provider SiteGround (and possibly others), and provides an option for fixing the issue. This guide should also work for other providers that exhibit the same issue (such as Amazon SES).

Issue
The user sending the form gets an error saying  if Manual:$wgSMTP has not been configured:



If Manual:$wgSMTP has been configured, then the user may get an error saying that the From address is not configured in the server.

Cause
As of Feb. 2022, SiteGround doesn't appear to allow sending emails when the From address is not in the list of email addresses of the corresponding SiteGround account. This is because, technically, MediaWiki is spoofing email addresses (if settings are not changed): it sends the contactee's email as the From address, even though it's actually from the account's wiki. Of course, it's only going to the account owner's personal email, and the email is labelled as a Contact (no harm, no foul)... but SiteGround, in its wisdom, still bars it.

Notice that other email functionality (such as a password reset or if the contactee doesn't provide an email address) is not affected because the From address in this case is the same as $wgPasswordSender, which would usually be the same email address in the SiteGround account.

A useful way to check if the email address itself is valid to trigger a password reset for any user. If the reset email sends successfully, then this guide should help you with the ContactPage issue. If you can't send a reset email, then you should look into fixing that first (by following the suggestion at Manual:$wgSMTP, for instance). Similarly, if you can't send an email to a user using Special:EmailUser, the problem probably lies elsewhere.

Fix
This will involve changing the code of a file in the ContactPage extension, and was taken from here, and by extension, here. In the wiki root directory, go to the file. Then, locate the below line:

This would usually be in line 286 or so (the exact line will depend on the ContactPage version you have). Then comment the below lines:

and replace it with

This fixes the main issue. However, if you stop here, the user will get an error (an exception of type "Error") if they choose the option to send a copy of the message to themselves. To fix that, we need to make some changes to another section of the file. Look for the string (in about line 450 or so)

Then comment the below lines:

and replace with

That's it. Save the file, and the problem should no longer occur.

What the fix does is forcefully set the From address to the email address in the SiteGround account, while setting the "replyto" to the email the user sets when they contact your wiki. This means that you can still reply to the user despite this change, and the email will go back to the user who sent the contact form.