only works like this when i view mail.pl directly from browser $send = MIME::Lite->new( From => 'test ', To => '', Bcc => 'admin2@web.com', Subject => 'test', 'X-Priority' => 1, 'X-MSMail-Priority' => 'High', Type => 'text/html', Data => 'demo' ); $send->send; } my $json = encode_json( { msg => "Mail Sent" } ); print $CGI->header( -type => 'application/json' ),$json;