in reply to Sending mails
Your question reads like an if statement already; so the program logic is there. What you need to do now is put together a fairly elementary control structure and consider the advice that is posted here:
How do I send an email with Perl (including an attachment)?
MB
In Section
Seekers of Perl Wisdom