u didnt clear, where u want to block spam mails, i mean, r u just a simple yahoo user, or u a network administrator... for a simple user, u cant block spam mails through IP, coz spamers doesnt use same IP always.. and mostly they use fake IPs.
But if u r an administrator, then u can block mails on your mail server, through IPs depending upon the firewall u r using, or spam filters.
but stil lit might help u to stop all spams, but might reduce it a little.
just block the IP / IP range on your network, for both port 25 and 110.
but as a user, u cant do it