CiviCRM error: send a valid username and password

CiviCRM Joomla logoI installed CiviCRM free client relations manager component version 4.0.8 into Joomla 1.7.3. CiviCRM has many great features, one of which is the optional CiviMail bulk e-mail component. CiviMail needs a cron job to process all the scheduled mailings that you intend to send out to your mailinglists, but I was having a hard time getting the cron job up and running.

I struggled setting up the cronjob through my hosts cPanel following the setting up the cron job exactly. What I did:

  1. I created the civicrm-wgetrc file (with no file extension), which included one single line:
    post-data=name=myjoomlausername&pass=joomlauserspassword&key=thesecretkey and put it to my web root.  
  2. I double checked both civicrm.settings.php files (one in components/com_civicrm and other in administrator/components/com_civicrm) to have the same thesecretkey value.
  3. I set the cron job to read the civicrm-wgetrc file and execute the file 
    http://www.example.org/administrator/components/com_civicrm/civicrm/bin/civimail.cronjob.php
    with a command like:

    */5 * * * * yourLinuxUserName wget -O - -q -t 1 export WGETRC=/home/myserverusername/civicrm-wgetrc
    http://www.example.org/administrator/components/com_civicrm/civicrm/bin/civimail.cronjob.php

Since I set my e-mail to get the logs, I received an error:
ERROR: You need to send a valid user name and password to execute this file 

I tried to run the civimail.cronjob.php straight from the browser including the required parametres, then everything worked and the e-mails were sent. The URL to run civimail.cronjob.php from the browser:
http://www.example.org/administrator/components/com_civicrm/civicrm/bin/civimail.cronjob.php?name=myjoomlausername&pass=joomlauserspassword&key=thesecretkey

I tried to remove export WGETRC=/home/myserverusername/civicrm-wgetrc from the cron job command and replace the URL with the URL that contains the parametres. Guess what, still I'd get the error ERROR: You need to send a valid user name and password to execute this file logged.

After almost giving up hope, I came across this CiviCRM forum post.


Solution for me

Use backslash before & in the parametres string (\&), so the final result as a working cron job:

*/5 * * * * wget -O - -q -t 1 http://myurl.com/administrator/components/com_civicrm/civicrm/bin/civimail.cronjob.php?name=joomla_username\&pass=joomla_users_password\&key=thesecretkey


Ps, here is a link about wget parametres

ADs top-right (2)

About me

Iinstructor of robotics (LEGO Mindstorms), computer teacher, IT support, web dev, currently studying cyber-physical systems engineering.

If you found a solution here, would you consider donating $25,000 for my next project?

Just kidding, 1$ would do fine.

Hope you found what you needed. Thanks for stepping by.