I’m working on a contact sync app that connects with Gmail accounts. The issue I’m facing is that my app still shows email addresses as active even after they’ve been removed from Google’s servers. This creates sync problems between my application and Gmail.
Does Google provide any API that can verify whether a specific Gmail address is still valid and active? I need to implement this check from within my Java code.
If there’s no direct API for this, what would be the most reliable approach to validate Gmail addresses programmatically? Any suggestions for handling this sync issue would be helpful.
yeah, there isn’t a direct api for that. you can try smtp validation to check if the gmail address is valid. just connect to the smtp server and see if it responds positively. be careful tho, it might produce false positives. third-party services like zerobounce are an option too, but they cost.
I encountered similar issues when building email verification features. The Gmail API itself doesn’t expose user existence endpoints for privacy reasons, which makes direct validation impossible through official channels. What worked for me was implementing a combination approach: first validate the email format using regex, then attempt SMTP connection but don’t rely solely on it since Gmail’s servers often return ambiguous responses to prevent harvesting. For contact sync specifically, I found that handling exceptions gracefully when attempting actual operations works better than pre-validation. When an email becomes invalid, the API calls will fail with specific error codes that you can catch and use to update your local database accordingly. This reactive approach proved more reliable than proactive validation in my experience.