mail()

Can we use mail() function in suitecrm ?
If yes then how could we use it, whenever i use it does not send email ywiss its hardcoded and Where to use it ?

Use the SugarPHPMailer Class, see example here

https://github.com/salesagility/SuiteCRM/blob/master/modules/AOP_Case_Updates/CaseUpdatesHook.php#L361

I have tried it too it give fatal error in logs given below:

Thu Jun 14 12:30:22 2018 [57585][18d186db-3231-5dcb-bd2f-5b11a03296a3][FATAL] ERROR: rmdir_recursive(): argument cache/themes/SuiteP/modules is not a file or a dir.

I’ve seen that error often before and I don’t think it is related to whatever you were doing with the Sugar PHP Mailer.

You can delete “cache/themes” directory and it will get recreated.