PHP邮件功能在本地工作,但不在实际站点上

I am using the PHP mail function to send an email (I know I should be using a library like Swift but this is a legacy app).

I have the following code - it definately works locally as I have installed the 'Test Mail Server Tool' to listen to all incoming emails on my localhost and it displays this as a pop-up, so I can be certain the current code does work from a code point of view.

However for some reason on the live server the email never seems to get delivered to the email address - can anyone suggest the most common problems for this? Note - the email it is sending to on the live site belongs to a 'Google Apps' email address (not sure if this has any effect using Google).

Code..

        $to = 'admin@mysite.com';
        $subject = 'Customer Comment';
        $message['headers'] =   'From: ' . $comment_data['contact-email'] . "
";
        $message['headers'] .=  'Content-type: text/html; charset=iso-8859-1' . "
";

        $m =    'Message Sent From: ' . $comment_data['contact-name']   . '<p />';
        $m .=   'Email Address: ' . $comment_data['contact-email']  . '<p />';
        $m .=   'Message Comment: ' . $comment_data['contact-comment']  . '<p />';
        $m .=   'Further Information Checkbox: ' . $site_info   . '<p />';
        $m .=   'Third Parties Checkbox: ' . $third_party   . '<p />';


        mail( $to, $subject, $m, $message['headers'] );

Okay the logs have found the problem.. just need to fix it now - Application-specific password required - this is a problem with 2 step verification, just something for others to take note of when having problems with Google Apps accounts!