PHP Function: You can either use the internal function, which is globally available in your installation or you use the HTTP based API.
HTTP Based API: With the HTTP based API you can also integrate external services - e.g. your servers could send you messages using curl / bash. An other good use case is to integrate slack into your server monitoring.
The Recipient should have the following format: #channel@YourBotName
@channel: This is the channel where the message post to. It can also be a person, just replace the @ with # .
@YourBotName: That name will be displayed in slack. You can set any Botname, it does not need to match any predefined value.