How to exit from mailx

Hello Guys,
I have created function which is as follow:
My function is working, but it's waiting after executing mailx command. If user will press Ctrl+d then only it is executing subsequent lines. I treid couple of options such as quit, exit, ., ETO, but it's not working. Is any one can help me? how can I terminate mailx as end of message?

Best Regards,
:wall:

mailx reads email from standard input. Since you haven't fed any input or file into it, it's trying to read from your keyboard.

mailx -s "New Email Found" $usr < messagefile

Thanks for your quick reply, it works.:b: