I am using Google Apps for email service. On my cPanel server, I have a script which sends email using PHP mail function. Script sends email to one of the email accounts of my domain.
The problem is, instead of delivering email to my Google account it is trying to deliver it locally and due to this I am getting no such user error.
Since you are using Google Apps email service for your domain, you will have to set “Remote Mail Exchanger” for your domain from WHM/cPanel.
If you have WHM access, go to DNS Functions -> Edit MX Entry -> Select the domain and click “Edit”. Now select “Remote Mail Exchanger” and save it.
Now your server should deliver emails to your Google Apps account instead of local.