특정 도메인의 특정 기간에 대한 이메일 통계를 가져올 수 있습니다.
특정 통계를 개선하는 방법에 관한 자세한 내용은 Gmail 사용자에게 보낸 메일이 차단되거나 스팸으로 분류되는 것을 방지하기를 참고하세요.
기간의 통계 가져오기
특정 기간의 통계를 가져오려면 도메인 및 기간으로
domains.domainStats.query()
를 호출합니다. 다음은 특정 기간의 이메일 통계를 가져오는 방법을 보여주는 코드 샘플입니다.
자바
/**
* Lists domain statistics for a specific date range.
*
* @param service Authorized Gmail PostmasterTools API instance.
* @param domainName The fully qualified domain name.
* @param startDate The first day of the date range for which to retrieve statistics.
* @param endDate The last day of the date range for which to retrieve statistics.
* @param pageSize The number of DomainStats to get per request.
* @param pageToken The nextPageToken value returned from a previous List request, if any.
* @return Response message for query domain stats request.
* @throws IOException
*/
public static QueryDomainStatsResponse queryDomainStats(PostmasterTools service, String domainName,
Date startDate, Date endDate, int pageSize,
String pageToken) throws IOException {
QueryDomainStatsResponse queryDomainStatsResponse = service.domains().domainStats()
.query("domains/" + domainName)
.setStartDate(startDate)
.setEndDate(endDate)
.setPageSize(pageSize)
.setPageToken(pageToken)
.execute();
System.out.println(queryDomainStatsResponse.toPrettyString());
return null;
}
Python
"""Queries the domain stats for a domain for a specific date range.
Args:
service: Authorized Gmail PostmasterTools API instance.
domain_name: The fully qualified domain name.
start_date: The first day of the date range for which to retrieve statistics.
end_date: The last day of the date range for which to retrieve statistics.
page_size: The number of DomainStats to get per request.
page_token: The nextPageToken value returned from a previous List request, if any.
Returns:
The domain stats of the domain for this date range.
"""
def query_domain_stats(service, domain_name, start_date, end_date, page_size, page_token):
"""Queries the domain stats for a domain for a specific date range.
Args:
service: Authorized Gmail PostmasterTools API instance.
domain_name: The fully qualified domain name.
start_date: The first day of the date range for which to retrieve statistics.
end_date: The last day of the date range for which to retrieve statistics.
page_size: The number of DomainStats to get per request.
page_token: The nextPageToken value returned from a previous List request, if any.
Returns:
The domain stats of the domain for this date range.
"""
try:
query = 'domains/' + domain_name
query_domain_stats_response = service.domains().domainStats().query(parent=query, startDate=start_date, endDate=endDate, pageSize=page_size, pageToken=page_token).execute();
print(query_domain_stats_response);
return query_domain_stats_response;
except errors.HttpError as err:
print('An error occurred: %s' % err)
if __name__ == '__main__':
main()
성공하면 응답 본문에 다음과 같은 구조의 DomainStats 페이지가 매겨진 배열이 포함됩니다.
{
"domainStats": [
{
object (DomainStats)
}
],
"nextPageToken": string
}
도메인의 규정 준수 상태 가져오기
도메인의 규정 준수 상태를 가져오려면 도메인으로
domains.getComplianceStatus()
를 호출합니다. 규정 준수 상태에는 SPF (발신자 정책 프레임워크), DKIM (도메인키 인증 이메일), DMARC (도메인 기반 메일 인증, 보고 및 확인)의 규정 준수 정보가 포함됩니다.
다음은 도메인의 규정 준수 상태를 가져오는 방법을 보여주는 코드 샘플입니다.
자바
/**
* Gets the compliance status for a domain.
*
* @param service Authorized Gmail PostmasterTools API instance.
* @param domainName The fully qualified domain name.
* @return The compliance status of the domain.
* @throws IOException
*/
public static ComplianceStatus getComplianceStatus(PostmasterTools service, String domainName) throws IOException {
String query = String.format("domains/%s/complianceStatus", domainName);
ComplianceStatus complianceStatus = service.domains().getComplianceStatus(query).execute();
System.out.println(complianceStatus.toPrettyString());
return complianceStatus;
}
Python
"""Gets the compliance status for a domain.
Args:
service: Authorized Gmail PostmasterTools API instance.
domain_name: The fully qualified domain name.
Returns:
The compliance status of the domain.
"""
def get_compliance_status(service, domain_name):
"""Gets the compliance status for a domain.
Args:
service: Authorized Gmail PostmasterTools API instance.
domain_name: The fully qualified domain name.
Returns:
The compliance status of the domain.
"""
try:
query = 'domains/%s/complianceStatus' %(domain_name)
compliance_status = service.domains().getComplianceStatus(name=query).execute();
print(compliance_status);
return compliance_status;
except errors.HttpError as err:
print('An error occurred: %s' % err)
성공하면 응답 본문에 ComplianceStatus 인스턴스가 포함됩니다.