Automatically replying to spam with your own message

I have a rule in Mail on the newest version of OS X that filters out spam and puts it in it’s own mailbox. I want to be able to reply to that message automatically with my own message that says something along the lines of “You sent me spam, but if you think your message was wrongly flagged, send your email to a different address of mine.” I do not want to simply just bounce the message.

Example: I have a rule set up so that when my .Mac account recieves email from my GMail account, it is supposed to automatically send an email back as if that recieved email was spam. Heres my code:


using terms from application "Mail"
	tell application "Mail"
		set theAddress to ""
		set theSender to "(my email address is here in the code)"
		set theSubject to "***undelivered mail***"
		set theBody to "Action required on your part

You sent an email to my mailing list address which is white listed to accept incoming emails *only* from those lists.
Please resend the email removing the -list from the address.
  
If you feel this message was flagged by mistake, please resend your message to (different email here).

-Linda"
		set myReply to make new outgoing message with properties {subject:theSubject, content:theBody & return & return}
		tell myReply
			set visible to true
			make new recipient at end of to recipients with properties {address:theAddress}
		end tell
		send myReply
	end tell
end using terms from

This sort of works, except as you can see I have left the 3rd line as "set theAddress to “” " because I’m not sure how to get the address from the sender of the email. Any suggestions?

Replying to spam is a bad idea – it validates your email address to the spammer who will then sell it to others as a known good address.

Agreed, bad idea. Never, ever, ever reply to spam. Also, set up your mail client so it doesn’t load images unless you tell it to. (Spammers embed remote image links that are unique, and they can see that a real person has read their spam when the image loads.)