I have 2 mail functions, like this:
mail( $from, '', 'mail1', $headers );
mail( $from, '', 'mail2', $headers );
If I test it with my own email address in the $from, sometimes I receive mail1 first and sometimes I receive mail2 first. I want to always receive mail1 first. I tried putting a usleep in between the 2 mail functions, but it didn’t work.
You can’t. The order in which you receive mails isn’t up to you. Mail may take many paths, and be delayed at any SMTP server along the way.
The best you could do would be to forge the date headers, making one e-mail appear to be sent a minute earlier than the other. Most mail clients will order them by date sent. Be cautious of this though, and don’t go too far with it. Spammers use the same tactics, and e-mail providers know this.