Emailing from MODX on HostGator (user registration and formIt)

Although I typically recommend SkyToaster for the best MODX hosting solution, I do very much like HostGator as well, for a big box hosting solution they do a great job and MODX runs nicely out of the gate.  However, one tricky issue with their hosting is getting MODX to send emails in certain cases.  

Take for example, a fresh installation of MODX where the admin user has been set to the installer's email address upon setup.  It is very common for a developer to use their own username and email during setup, which installs as the default admin user, as well as setting the "Registration Email From Address" with the key " emailsender" to the administrator's email address.  

To find this setting in MODX 2.3 or higher click or hover over the gear icon on the right side of the main menu (next to your username) and go to System Settings -> Authentication and Security, or in System Settings put emailsender in the search filter.  In MODX 2.2 or lower go to System -> System Settings the top menu.

On many hosts, this is not a problem however it becomes an issue when the site is hosted at HostGator and possibly many other hosts as well.  You'll know if it's a problem if you don't receive your registration email when you install MODX, or when you've got a working formIt form but never receive any of your test emails.

Another useful tool for checking to see if MODX is sending emails is to use Bob Ray's QuickEmail snippet, found in Package Management or at http://modx.com/extras/package/quickemail.  If QuickEmail checks out using:

	

yet you do not receive an email, you've got a working MODX mailer but something is preventing MODX from actually sending the email.  

In the case of HostGator hosting or other servers configured similarly, try the following:

The emailsender must be a valid email address for the hosted domain.  

This means you must use either use an existing siteDomain.com email address for emailsender, or if there are none yet, create one and change the emailsender system setting to the domain's valid email address.

This will allow MODX to send registration emails and solve half of the problem, but it does not allow snippets such as formIt to send mail.

The solution is pretty simple, just add an additional parameter to the formIt snippet call and make sure it is a valid email for the domain:

	 &emailFrom=`email@yourDomain.com` 

That's it!  Your forms and registration emails should work now.

You can test your emails by either creating a new user in MODX and checking for the registration email, or by testing your form.