How can we hit/run the rules using code I have defined a rule in " Configuration » Workflow » Rules". 
I have setup this as following...

EVENT : After saving a new account
Conditions : User has role(s) 
             And role is (Referral Source) 
    enter code here
Actions  Send a HTML mail.

But it's not sending the mail to register user. It's because of the user don't have the role as Referral Source at the same time. I am assigning the role using the PHP code and I would like to run the rule on same time. So how can I do that?
Create first rule "After saving a new user account" action "Add user role" to user and set its priority first(by set its weight 0 in SETTINGS of rule) and create one another rule for the same and set condition for role is(Reffereal source) and action send a HTML mail, set its priority down (by set its weight 1 in SETTINGS of rule) will work for you.