Joomla Contact Us Form Issue – PHPMAILER_RECIPIENTS_FAILED

PHPMAILER_RECIPIENTS_FAILED

Some times this error occurs because default contact form tries to use users email address as the FROM address. Some hosts doesn’t allow this to stop spam.

So we need to change the FROM address to the Joomla configurations FROM address in the line 162 of file components/com_contact/controller.php.

After that , for convenience, we can add users email as REPLY TO address.
alter:

line 162 of file components/com_contact/controller.php.

Code:
$mail->setSender( array( $email, $name ) );
to:

Code:
$mail->setSender( array( $MailFrom, $name ) );
$mail->addReplyTo( array( $email, $name ) );

There may be other reasons to cause this error , this is just a one case and this case is hard to find since the mail error doesn’t generate much information.

Database Error: Unable to connect to the database:Could not connect to database

You should check the configuration.php file of your Joomla application and make sure the following lines are correct:

var $dbtype = ‘mysql’;
var $host = ‘localhost’;
var $user = ‘user_name’;
var $password = ‘YourPassword’;
var $db = ‘database_name’;
var $dbprefix = ‘jos_’;
You should make sure you are using the correct MySQL username and database in your configuration.php file. You can use the MySQL Databases tool in your cPanel in order to check the correct username and database for your Joomla. In addition, make sure that your MySQL username is added to your database. This issue can also be caused by errors within the database itself. In such cases you can try restoring your Joomla database.

Joomla Tip : Creating a new file on a joomla installation

Whenever creating a new file for the Joomla! installation you must avoid using certain text editors such as , WordPad, Word, for example as they unfortunately have a tendency to add unwanted and unnecessary code that may cause problems later on. Always remember to save files in plain text format.

How to add CSS and Javascript to Your Joomla Extension

When creating a quality Joomla extension you will place your styles and javascript codes on seperate files.

Then here is the way to add those files in to the joomla extension the proper way.

$document = JFactory::getDocument();
$document->addStyleSheet(JURI::root().’mod_name/css/stylesheet.css’);
$document->addScript(JURI::root(). ‘mod_name/js/script.js’);

Redirecting non-www to www with .htaccess

If you want to redirect all non www requests to your web site to the www version, all you need to do is add the following code to your .htaccess file: Needless to say that you must be running on apache with mod_rewrite enabled.

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

Redirecting www to non-www 

RewriteEngine On
RewriteCond %{HTTP_HOST} !^my-domain\.com$ [NC]
RewriteRule ^(.*)$ http://my-domain.com/$1 [R=301,L]