to disable it you can just remove those files that are sending out spam.
In this case it's the one with the mailer functions:
but a better way of doing it would be like this:
first create a file called env.php
inside this file put the following code
This should tell you where your php.ini file is.
Inside that file (search for the section where functions are setup)
and add the line
disabled_functions = mail
I'm guessing that you've just installed something (in this case Wordpress) out of the box in order to get a website up and running quickly. the trouble with doing that is often you will have functions enabled that you really don't need.