CiviCRM error: send a valid username and password
I 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:
- 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.
- 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.
- I set the cron job to read the civicrm-wgetrc file and execute the file
with a command like:
*/5 * * * * yourLinuxUserName wget -O - -q -t 1 export WGETRC=/home/myserverusername/civicrm-wgetrc
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:
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.