A couple of points on style ( since the answer is already provided ):
- use strict
- You seem to be setting $toemail and $fromemail as global variables - you should consider scoping them as lexicals, and passing them explicitly to the function: emailme( $fromemail, $toemail ). This will make your code much easier to debug.
- Consider using join in your print statement:
print DATAFILEOUT ( join '|', $company_name, $time, ... );
This also helps avoid typos, and lets you add and remove parameters more easily.