PHP 7/8에서는 App Engine Mail 함수가 더 이상 기본적으로 오버로드되지 않으므로 이를 명시적으로 사용 설정해야 합니다. 이 새로운 동작을 통해 필요에 맞게 Mail 함수의 용도를 변경할 수 있습니다. 이렇게 하면 모든 Mail 함수 호출에 현재 사용 중인 구현을 확인할 수 있습니다.
기본 PHP mail() 함수를 사용하여 App Engine Mail API를 사용해 메일을 보내려면 다음과 같이 php.ini 파일에서 이를 사용 설정할 수 있습니다.
// Notice that $image_content_id is the optional Content-ID header value of the// attachment. Must be enclosed by angle brackets (<>)$image_content_id = '<image-content-id>';// Pull in the raw file data of the image file to attach it to the message.$image_data = file_get_contents('image.jpg');try { $message = new Message(); $message->setSender('from@example.com'); $message->addTo('to@example.com'); $message->setSubject('Example email'); $message->setTextBody('Hello, world!'); $message->addAttachment('image.jpg', $image_data, $image_content_id); $message->send(); echo 'Mail Sent';} catch (InvalidArgumentException $e) { echo 'There was an error';
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["이해하기 어려움","hardToUnderstand","thumb-down"],["잘못된 정보 또는 샘플 코드","incorrectInformationOrSampleCode","thumb-down"],["필요한 정보/샘플이 없음","missingTheInformationSamplesINeed","thumb-down"],["번역 문제","translationIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-09-04(UTC)"],[[["\u003cp\u003eThis guide details how to utilize the Mail API for sending emails.\u003c/p\u003e\n"],["\u003cp\u003eThe API is compatible with first-generation runtimes and is usable when upgrading to corresponding second-generation runtimes.\u003c/p\u003e\n"],["\u003cp\u003eTo send emails you must register your sender emails as authorized senders.\u003c/p\u003e\n"]]],[],null,["# Sending mail with the Mail API\n\nGo Java PHP Python\n\nThis guide describes how to use the Mail API to send mail.\n\n\u003cbr /\u003e\n\n| This API is supported for first-generation runtimes and can be used when [upgrading to corresponding second-generation runtimes](/appengine/docs/standard/\n|\n| /services/access). If you are updating to the App Engine runtime, refer to the [Upgrade to second-generation runtimes]() page to learn about your migration options for legacy bundled services.\n\nBefore you begin\n----------------\n\nRegister your sender emails as authorized senders. For more information, see\n[who can send email](/appengine/docs/standard/services/mail#who_can_send_mail).\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e"]]