Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.
Try this. I haven't tested it much.

Open AppleScript Editor. Paste in the code below with the following replacements:
  • [BLOCKED NUMBER] is the blocked number in format "+15555555555"
  • [YOUR EMAIL] is the iCloud email address used for the current account
  • [BLOCKEDOUTPUT] is the text to be displayed when the blocked sender sends a message

Code:
property blockedNumber : "[BLOCKED NUMBER]"
property yourEmail : "E:[YOUR EMAIL]"
property blockedOutput : "[BLOCKED OUTPUT]"

using terms from application "Messages"
	
	on received text invitation theText from theBuddy for theChat
		
	end received text invitation
	
	on received audio invitation theText from theBuddy for theChat
		
	end received audio invitation
	
	on received video invitation theText from theBuddy for theChat
		
	end received video invitation
	
	on received remote screen sharing invitation from theBuddy for theChat
		
	end received remote screen sharing invitation
	
	on received local screen sharing invitation from theBuddy for theChat
		
	end received local screen sharing invitation
	
	on received file transfer invitation theFileTransfer
		
	end received file transfer invitation
	
	on buddy authorization requested theRequest
		
	end buddy authorization requested
	
	on message sent theMessage for theChat
		
	end message sent
	
	on message received theMessage from theBuddy for theChat
		set blockedBuddy to buddy blockedNumber of service yourEmail
		if theBuddy is equal to blockedBuddy then
			return blockedOutput as string
		end if
	end message received
	
	on chat room message received theMessage from theBuddy for theChat
		set blockedBuddy to buddy blockedNumber of service yourEmail
		if theBuddy is equal to blockedBuddy then
			return blockedOutput as string
		end if
	end chat room message received
	
	on active chat message received theMessage from theBuddy
		set blockedBuddy to buddy blockedNumber of service yourEmail
		if theBuddy is equal to blockedBuddy then
			return blockedOutput as string
		end if
	end active chat message received
	
	on addressed chat room message received theMessage from theBuddy for theChat
		set blockedBuddy to buddy blockedNumber of service yourEmail
		if theBuddy is equal to blockedBuddy then
			return blockedOutput as string
		end if
	end addressed chat room message received
	
	on addressed message received theMessage from theBuddy for theChat
		set blockedBuddy to buddy blockedNumber of service yourEmail
		if theBuddy is equal to blockedBuddy then
			return blockedOutput as string
		end if
	end addressed message received
	
	on av chat started
		
	end av chat started
	
	on av chat ended
		
	end av chat ended
	
	on login finished for theService
		
	end login finished
	
	on logout finished for theService
		
	end logout finished
	
	on buddy became available theBuddy
		
	end buddy became available
	
	on buddy became unavailable theBuddy
		
	end buddy became unavailable
	
	on completed file transfer
		
	end completed file transfer
end using terms from

Now, save the file to your desktop as "Blocked" using file format "Text."

Open the Messages app. Go to preferences. Under AppleScript handler choose "Open Scripts Folder." Drag the file from your desktop into the scripts folder. "Blocked.applescript" should now appear as an AppleScript handler option. Select it.

You could also use "decline theChat" if you do not even want to know that the person is trying to contact you.

Thank you for your input! I did try doing this following your instruction, asked a friend to test it, but it was as if nothing changed, so I suppose it didn't work for me? Also I would prefer the option where I wouldn't even want to know that this person is trying to contact me, but I can't understand what you meant by using "decline theChat"
 
Easy fix will be to change the imessage address on the mac, disable the phone number on the mac and just setup to accept imessage sent to the particular email, if he knows the email you can just use a different one or in the case of a @me emaio you can use the alternative domain @icloud and you will never heard from that person again.
 
Thank you for your input! I did try doing this following your instruction, asked a friend to test it, but it was as if nothing changed, so I suppose it didn't work for me? Also I would prefer the option where I wouldn't even want to know that this person is trying to contact me, but I can't understand what you meant by using "decline theChat"

The code does work on mine, so my guess is the problem has to do with accessing the iCloud service. Does the email line look like this?

Code:
property yourEmail : "E:youraddress@host.com"

I think the E: is necessary. You could try some of the different ways to access the iCloud service talked about in this discussion. Specifically, you could try

Code:
property yourEmail : "iCloud"

You could also replace every occurrence of these lines

Code:
		set blockedBuddy to buddy blockedNumber of service yourEmail
		if theBuddy is equal to blockedBuddy then
			return blockedOutput as string
		end if

with

Code:
                set iCloudService to get id of first service
		set blockedBuddy to buddy blockedNumber of iCloudService
		if theBuddy is equal to blockedBuddy then
			return blockedOutput as string
		end if

To avoid all notices of the messages, you should be able to replace

Code:
return blockedOutput as string

with

Code:
decline theChat

You might also try asking this question in the programming forum. Someone experienced with AppleScript would be able to provide a general solution very easily.
 
I refined the script a little, allowing for multiple blocked numbers and options to log blocks and the contents of the messages to a file.

Code:
property blockedList : {"+9735551212", "+6035551212", "+12035551212"}
property yourEmail : "E:kenxxxxx@gmail.com"
property logBlocks : true
property logMessageContents : false
property logFileName : "Macintosh HD:Users:kenv99:Documents:Blocked Messages Log"

using terms from application "Messages"
	
	on buddy authorization requested theAuth
		repeat with blockedNumber in blockedList
			set blockedBuddy to buddy blockedNumber of service yourEmail
			set authBuddy to buddy of theAuth
			if authBuddy is equal to blockedBuddy then
				decline theAuth
				if logBlocks is true then
					set this_data to ((current date) as string) & space & "Buddy Auth Declined to: " & ((blockedNumber) as string) & return
					set this_file to (logFileName as string)
					my write_to_file(this_data, this_file, true)
				end if
			end if
		end repeat
	end buddy authorization requested
	
	on received text invitation theMessage from theBuddy for theChat
		repeat with blockedNumber in blockedList
			set blockedBuddy to buddy blockedNumber of service yourEmail
			if theBuddy is equal to blockedBuddy then
				decline theChat
				if logBlocks is true then
					if logMessageContents is true then
						set this_data to ((current date) as string) & space & "Rec'd Text Invite Declined to: " & ((blockedNumber) as string) & space & (theMessage as string) & return
					else
						set this_data to ((current date) as string) & space & "Rec'd Text Invite Declined to: " & ((blockedNumber) as string) & return
					end if
					set this_file to (logFileName as string)
					my write_to_file(this_data, this_file, true)
				end if
			end if
		end repeat
	end received text invitation
	
	on message received theMessage from theBuddy for theChat
		display dialog (get name of theBuddy)
		repeat with blockedNumber in blockedList
			set blockedBuddy to buddy blockedNumber of service yourEmail
			if theBuddy is equal to blockedBuddy then
				decline theChat
				if logBlocks is true then
					if logMessageContents is true then
						set this_data to ((current date) as string) & space & "Msg Rec'd Declined to: " & ((blockedNumber) as string) & space & (theMessage as string) & return
					else
						set this_data to ((current date) as string) & space & "Msg Rec'd Declined to: " & ((blockedNumber) as string) & return
					end if
				end if
			end if
		end repeat
	end message received
	
	on chat room message received theMessage from theBuddy for theChat
		display dialog (get name of theBuddy)
		repeat with blockedNumber in blockedList
			set blockedBuddy to buddy blockedNumber of service yourEmail
			if theBuddy is equal to blockedBuddy then
				decline theChat
				if logBlocks is true then
					if logMessageContents is true then
						set this_data to ((current date) as string) & space & "Chat Msg Rec'd Declined to: " & ((blockedNumber) as string) & space & (theMessage as string) & return
					else
						set this_data to ((current date) as string) & space & "Chat Msg Rec'd Declined to: " & ((blockedNumber) as string) & return
					end if
					set this_file to (logFileName as string)
					my write_to_file(this_data, this_file, true)
				end if
			end if
		end repeat
	end chat room message received
	
	on active chat message received theMessage from theBuddy for theChat
		display dialog (get name of theBuddy)
		repeat with blockedNumber in blockedList
			set blockedBuddy to buddy blockedNumber of service yourEmail
			if theBuddy is equal to blockedBuddy then
				decline theChat
				if logBlocks is true then
					if logMessageContents is true then
						set this_data to ((current date) as string) & space & "Active Chat Msg Declined to: " & ((blockedNumber) as string) & space & (theMessage as string) & return
					else
						set this_data to ((current date) as string) & space & "Active Chat Msg Declined to: " & ((blockedNumber) as string) & return
					end if
					set this_file to (logFileName as string)
					my write_to_file(this_data, this_file, true)
				end if
			end if
		end repeat
	end active chat message received
	
	on addressed chat room message received theMessage from theBuddy for theChat
		display dialog (get name of theBuddy)
		repeat with blockedNumber in blockedList
			set blockedBuddy to buddy blockedNumber of service yourEmail
			if theBuddy is equal to blockedBuddy then
				decline theChat
				if logBlocks is true then
					if logMessageContents is true then
						set this_data to ((current date) as string) & space & "Addressed Chat Msg Declined to: " & ((blockedNumber) as string) & space & (theMessage as string) & return
					else
						set this_data to ((current date) as string) & space & "Addressed Chat Msg Declined to: " & ((blockedNumber) as string) & return
					end if
					set this_file to (logFileName as string)
					my write_to_file(this_data, this_file, true)
				end if
			end if
		end repeat
	end addressed chat room message received
	
	on addressed message received theMessage from theBuddy for theChat
		display dialog (get name of theBuddy)
		repeat with blockedNumber in blockedList
			set blockedBuddy to buddy blockedNumber of service yourEmail
			if theBuddy is equal to blockedBuddy then
				decline theChat
				if logBlocks is true then
					if logMessageContents is true then
						set this_data to ((current date) as string) & space & "Addressed Msg Declined to: " & ((blockedNumber) as string) & space & (theMessage as string) & return
					else
						set this_data to ((current date) as string) & space & "Addressed Msg Declined to: " & ((blockedNumber) as string) & return
					end if
					set this_file to (logFileName as string)
					my write_to_file(this_data, this_file, true)
				end if
			end if
		end repeat
	end addressed message received
	
	on received video invitation theText from theBuddy for theChat
		repeat with blockedNumber in blockedList
			set blockedBuddy to buddy blockedNumber of service yourEmail
			if theBuddy is equal to blockedBuddy then
				decline theChat
				if logBlocks is true then
					if logMessageContents is true then
						set this_data to ((current date) as string) & space & "Video Invite Declined to: " & ((blockedNumber) as string) & space & (theText as string) & return
					else
						set this_data to ((current date) as string) & space & "Video Invite Declined to: " & ((blockedNumber) as string) & return
					end if
					set this_file to (logFileName as string)
					my write_to_file(this_data, this_file, true)
				end if
			end if
		end repeat
	end received video invitation
	
	on av chat started
		
	end av chat started
	
	on av chat ended
		
	end av chat ended
	
	on login finished for theService
		
	end login finished
	
	on logout finished for theService
		
	end logout finished
	
	on buddy became available theBuddy
		
	end buddy became available
	
	on buddy became unavailable theBuddy
		
	end buddy became unavailable
	
	on completed file transfer
		
	end completed file transfer
	
	on received audio invitation theText from theBuddy for theChat
		
	end received audio invitation
	
	on received remote screen sharing invitation from theBuddy for theChat
		
	end received remote screen sharing invitation
	
	on received local screen sharing invitation from theBuddy for theChat
		
	end received local screen sharing invitation
	
	on received file transfer invitation theFileTransfer
		
	end received file transfer invitation
	
	on message sent theMessage for theChat
		
	end message sent
	
end using terms from

on write_to_file(this_data, target_file, append_data)
	try
		set the target_file to the target_file as string
		set the open_target_file to open for access file target_file with write permission
		if append_data is false then set eof of the open_target_file to 0
		write this_data to the open_target_file starting at eof
		close access the open_target_file
		return true
	on error
		try
			close access file target_file
		end try
		return false
	end try
end write_to_file
 
Long time reader, first time poster. I'm typically fairly reserved and don't really participate in community discussion, but today I do terribly need the help of the community.

There's a man that's been harassing my wife and I via iMessage, and it's a person that we've had a difficult past with. Without going further into detail, he brings up troubling memories and stirs up all sorts of negative emotions between my wife and I. This has been causing constant stress/rifts in our marriage. I have tried blocking him through iOS7, and while this works just fine on phones, it does not register on OSX itself. So messages get through regardless.

We cannot stop using iMessage all together, as we have many, many elderly family/relatives that use the service, and cannot have them all switch to something different. I've called and asked help of Apple support, but to no avail. I've come to this board looking some kind of solution, maybe if I mess with some internal files of the Messages app? or even a script perhaps that will block any incoming messages from this particular person.

I'd really, really appreciate any and all help. Thank you.

I don't know if you have gotten this response yet, but, if you have, I will go ahead and support the idea that you should make this a legal matter. Something more concrete than a simple 'block' on the internet.
 
I don't know if you have gotten this response yet, but, if you have, I will go ahead and support the idea that you should make this a legal matter. Something more concrete than a simple 'block' on the internet.

I have been in this situation. Do BOTH. That is one reason that I included a way to log the messages instead of just blocking them. It is the constant intrusion that needs to stop right away. But if you decide to pursue things legally, you can bring the log if you decide to file a complaint. In my situation, the person harassing me lived on the other side of the country. I went to the local police and provided them as much hard evidence of harassment that I could. I was told if I wanted to file a formal complaint, I would need to do so in person at her local police station. Flying out there to file a complaint would have just validated her. Eventually my local law enforcement officials contacted the station local to her and they paid her a visit. There were a few lingering attempts after that. Then it finally stopped. For me the biggest issue was her getting burner phones or using ip voice so that there was always a new number to block that I hadn't seen before.
 
Small bugs fixed:

Code:
property blockedList : {"+9735551212", "+6035551212", "+12035551212", "+16615551212"}
property yourEmail : "E:kenxxxx@gmail.com"
property logBlocks : true
property logMessageContents : false
property logFileName : "Macintosh HD:Users:kenv99:Documents:Blocked Messages Log"

using terms from application "Messages"
	
	on buddy authorization requested theAuth
		repeat with blockedNumber in blockedList
			set blockedBuddy to buddy blockedNumber of service yourEmail
			set authBuddy to buddy of theAuth
			if authBuddy is equal to blockedBuddy then
				decline theAuth
				if logBlocks is equal to true then
					set this_data to ((current date) as string) & space & "Buddy Auth Declined to: " & ((blockedNumber) as string) & return
					set this_file to (logFileName as string)
					my write_to_file(this_data, this_file, true)
				end if
			end if
		end repeat
	end buddy authorization requested
	
	on received text invitation theMessage from theBuddy for theChat
		repeat with blockedNumber in blockedList
			set blockedBuddy to buddy blockedNumber of service yourEmail
			if theBuddy is equal to blockedBuddy then
				decline theChat
				if logBlocks is equal to true then
					if logMessageContents then
						set this_data to ((current date) as string) & space & "Rec'd Text Invite Declined to: " & ((blockedNumber) as string) & space & (theMessage as string) & return
					else
						set this_data to ((current date) as string) & space & "Rec'd Text Invite Declined to: " & ((blockedNumber) as string) & return
					end if
					set this_file to (logFileName as string)
					my write_to_file(this_data, this_file, true)
				end if
			end if
		end repeat
	end received text invitation
	
	on message received theMessage from theBuddy for theChat
		repeat with blockedNumber in blockedList
			set blockedBuddy to buddy blockedNumber of service yourEmail
			if theBuddy is equal to blockedBuddy then
				decline theChat
				if logBlocks is equal to true then
					if logMessageContents then
						set this_data to ((current date) as string) & space & "Msg Rec'd Declined to: " & ((blockedNumber) as string) & space & (theMessage as string) & return
					else
						set this_data to ((current date) as string) & space & "Msg Rec'd Declined to: " & ((blockedNumber) as string) & return
					end if
					set this_file to (logFileName as string)
					my write_to_file(this_data, this_file, true)
				end if
			end if
		end repeat
	end message received
	
	on chat room message received theMessage from theBuddy for theChat
		repeat with blockedNumber in blockedList
			set blockedBuddy to buddy blockedNumber of service yourEmail
			if theBuddy is equal to blockedBuddy then
				decline theChat
				if logBlocks is equal to true then
					if logMessageContents then
						set this_data to ((current date) as string) & space & "Chat Msg Rec'd Declined to: " & ((blockedNumber) as string) & space & (theMessage as string) & return
					else
						set this_data to ((current date) as string) & space & "Chat Msg Rec'd Declined to: " & ((blockedNumber) as string) & return
					end if
					set this_file to (logFileName as string)
					my write_to_file(this_data, this_file, true)
				end if
			end if
		end repeat
	end chat room message received
	
	on active chat message received theMessage from theBuddy for theChat
		repeat with blockedNumber in blockedList
			set blockedBuddy to buddy blockedNumber of service yourEmail
			if theBuddy is equal to blockedBuddy then
				decline theChat
				if logBlocks is equal to true then
					if logMessageContents then
						set this_data to ((current date) as string) & space & "Active Chat Msg Declined to: " & ((blockedNumber) as string) & space & (theMessage as string) & return
					else
						set this_data to ((current date) as string) & space & "Active Chat Msg Declined to: " & ((blockedNumber) as string) & return
					end if
					set this_file to (logFileName as string)
					my write_to_file(this_data, this_file, true)
				end if
			end if
		end repeat
	end active chat message received
	
	on addressed chat room message received theMessage from theBuddy for theChat
		repeat with blockedNumber in blockedList
			set blockedBuddy to buddy blockedNumber of service yourEmail
			if theBuddy is equal to blockedBuddy then
				decline theChat
				if logBlocks is equal to true then
					if logMessageContents then
						set this_data to ((current date) as string) & space & "Addressed Chat Msg Declined to: " & ((blockedNumber) as string) & space & (theMessage as string) & return
					else
						set this_data to ((current date) as string) & space & "Addressed Chat Msg Declined to: " & ((blockedNumber) as string) & return
					end if
					set this_file to (logFileName as string)
					my write_to_file(this_data, this_file, true)
				end if
			end if
		end repeat
	end addressed chat room message received
	
	on addressed message received theMessage from theBuddy for theChat
		repeat with blockedNumber in blockedList
			set blockedBuddy to buddy blockedNumber of service yourEmail
			if theBuddy is equal to blockedBuddy then
				decline theChat
				if logBlocks is equal to true then
					if logMessageContents then
						set this_data to ((current date) as string) & space & "Addressed Msg Declined to: " & ((blockedNumber) as string) & space & (theMessage as string) & return
					else
						set this_data to ((current date) as string) & space & "Addressed Msg Declined to: " & ((blockedNumber) as string) & return
					end if
					set this_file to (logFileName as string)
					my write_to_file(this_data, this_file, true)
				end if
			end if
		end repeat
	end addressed message received
	
	on received video invitation theText from theBuddy for theChat
		repeat with blockedNumber in blockedList
			set blockedBuddy to buddy blockedNumber of service yourEmail
			if theBuddy is equal to blockedBuddy then
				decline theChat
				if logBlocks is equal to true then
					if logMessageContents then
						set this_data to ((current date) as string) & space & "Video Invite Declined to: " & ((blockedNumber) as string) & space & (theText as string) & return
					else
						set this_data to ((current date) as string) & space & "Video Invite Declined to: " & ((blockedNumber) as string) & return
					end if
					set this_file to (logFileName as string)
					my write_to_file(this_data, this_file, true)
				end if
			end if
		end repeat
	end received video invitation
	
	on av chat started
		
	end av chat started
	
	on av chat ended
		
	end av chat ended
	
	on login finished for theService
		
	end login finished
	
	on logout finished for theService
		
	end logout finished
	
	on buddy became available theBuddy
		
	end buddy became available
	
	on buddy became unavailable theBuddy
		
	end buddy became unavailable
	
	on completed file transfer
		
	end completed file transfer
	
	on received audio invitation theText from theBuddy for theChat
		
	end received audio invitation
	
	on received remote screen sharing invitation from theBuddy for theChat
		
	end received remote screen sharing invitation
	
	on received local screen sharing invitation from theBuddy for theChat
		
	end received local screen sharing invitation
	
	on received file transfer invitation theFileTransfer
		
	end received file transfer invitation
	
	on message sent theMessage for theChat
		
	end message sent
	
end using terms from

on write_to_file(this_data, target_file, append_data)
	try
		set the target_file to the target_file as string
		set the open_target_file to open for access file target_file with write permission
		if append_data is false then set eof of the open_target_file to 0
		write this_data to the open_target_file starting at eof
		close access the open_target_file
		return true
	on error
		try
			close access file target_file
		end try
		return false
	end try
end write_to_file
 
You can block people with 10.9.2 now

Thanks. It actually brought them in directly from my phone. Great news...
It took a few minutes for me to sort it out. Anyone else wondering, go to Messages -> Preferences -> Accounts -> Blocked.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.