It runs the program defined in sendmail_path
to submit the message for delivery. Even if you are running something like Postfix or qmail as the mail transfer agent (MTA) on your server, it will provide a suitable program (probably named "sendmail") to perform this function. Once the message is submitted, it will be queued for delivery by your MTA.
Note that it may be inefficient to send a large number of messages in a loop using mail() - PHP recommends looking at some alternatives
for this purpose.