I am new to perl and have a requirement to send email from perl script running on the linux environment. I need to define the 'from' address in the syntax as well. The below command when run on linux works fine:

Code

mail -s subject to_address -- -f from_address

However when i try the same from Perl script using the below code it gives me the error:

Thanks a lot for the reply! Will definitely go through it. However, i doubt that i have the function written in wrong way or i am not calling it properly because if i type the below statement (not function) in a perl script and execute it, it sends the email: