PHP 5는 지원이 종료되었으며 2026년 1월 31일에 지원 중단됩니다. 지원 중단 후에는 조직에서 이전에 조직 정책을 사용하여 레거시 런타임의 배포를 다시 사용 설정한 경우에도 PHP 5 애플리케이션을 배포할 수 없습니다. 기존 PHP 5 애플리케이션은 지원 중단 날짜 이후에도 계속 실행되고 트래픽을 수신합니다. 지원되는 최신 PHP 버전으로 마이그레이션하는 것이 좋습니다.
보내는 사람의 이메일을 승인된 보내는 사람으로 등록해야 합니다. 자세한 내용은 이메일을 보낼 수 있는 사람을 참조하세요.
메일 보내기
PHP의 기본 제공 mail() 함수는 App Engine Mail API를 통해 이메일을 보낼 수 있습니다. 이 함수는 메일 보내기에 나와 있는 제한사항을 준수하는 대부분의 기존 코드에서 원활하게 작동합니다.
또는 Mail API를 직접 호출할 수도 있습니다.
use google\appengine\api\mail\Message;// 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';}
메일 받기
수신 이메일을 다음과 같은 형식의 주소로 받도록 설정할 수 있습니다.
anything@appid.appspotmail.com
이메일을 받으려면 다음 안내를 따르세요.
앱의 app.yaml 파일에서 수신 메일을 사용 설정합니다. inbound_services에 다음을 추가합니다.
-mail
구성 파일에서, 이메일 주소를 나타내는 URL 경로에서 애플리케이션 코드의 핸들러로의 매핑을 생성합니다. /_ah/mail/.+ 패턴은 모든 수신 이메일 주소와 일치합니다.
[[["이해하기 쉬움","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 outlines how to utilize the Mail API for sending and receiving emails within the context of App Engine, particularly for first-generation runtimes.\u003c/p\u003e\n"],["\u003cp\u003ePHP's built-in \u003ccode\u003email()\u003c/code\u003e function can send emails using the App Engine Mail API, and direct calls to the API are also possible using the \u003ccode\u003egoogle\\appengine\\api\\mail\\Message\u003c/code\u003e class.\u003c/p\u003e\n"],["\u003cp\u003eBefore sending emails, you must register your sender email addresses as authorized senders, according to the Mail API's guidelines.\u003c/p\u003e\n"],["\u003cp\u003eTo receive emails, enable incoming mail in your \u003ccode\u003eapp.yaml\u003c/code\u003e file, create URL mappings for incoming email addresses, and implement handlers in your app's code to process the received mail using the Mailparse extension.\u003c/p\u003e\n"],["\u003cp\u003eYour app can receive incoming emails at addresses formatted as \u003ccode\u003eanything@appid.appspotmail.com\u003c/code\u003e, even if your app is deployed on a custom domain, as you cannot use custom domain addresses to receive emails.\u003c/p\u003e\n"]]],[],null,["# Sending and Receiving Mail with the Mail API\n\nThis guide describes how to use the Mail API to send and receive mail.\n| This API is supported for first-generation runtimes and can be used when [upgrading to corresponding second-generation runtimes](/appengine/docs/standard/\n| php-gen2\n|\n| /services/access). If you are updating to the App Engine PHP 7/8 runtime, refer to the [migration guide](/appengine/migration-center/standard/migrate-to-second-gen/php-differences) to learn about your migration options for legacy bundled services.\n\nBefore you begin\n----------------\n\nYou must register your sender emails as authorized senders. For more\ninformation, see\n[who can send email](/appengine/docs/legacy/standard/python/mail#who_can_send_mail).\n\nSending mail\n------------\n\nPHP's built-in [`mail()`](https://php.net/manual/en/function.mail.php)\nfunction can send emails via App Engine Mail API. This should work well with\nmost existing code as long as it conforms to the restrictions listed in the\n[Sending mail](#Sending_mail).\n\nAlternatively, you can make direct calls to the Mail API: \n\n use google\\appengine\\api\\mail\\Message;\n\n // Notice that $image_content_id is the optional Content-ID header value of the\n // attachment. Must be enclosed by angle brackets (\u003c\u003e)\n $image_content_id = '\u003cimage-content-id\u003e';\n\n // Pull in the raw file data of the image file to attach it to the message.\n $image_data = file_get_contents('image.jpg');\n\n try {\n $message = new Message();\n $message-\u003esetSender('from@example.com');\n $message-\u003eaddTo('to@example.com');\n $message-\u003esetSubject('Example email');\n $message-\u003esetTextBody('Hello, world!');\n $message-\u003eaddAttachment('image.jpg', $image_data, $image_content_id);\n $message-\u003esend();\n echo 'Mail Sent';\n } catch (InvalidArgumentException $e) {\n echo 'There was an error';\n }\n\nReceiving mail\n--------------\n\nYou can set up your app to receive incoming email at addresses in the following\nformat: \n\n anything@appid.appspotmail.com\n\n| **Note:** Even if your app is deployed on a custom domain, you can't receive email sent to addresses in that domain.\n\nTo receive email:\n\n1. Enable incoming mail in your app's `app.yaml` file. Add the following to the\n `inbound_services`:\n\n - mail\n\n2. In your configuration file, create mappings from URL paths that represent\n email addresses to handlers in your app's code. The pattern `/_ah/mail/.+`\n matches all incoming email addresses:\n\n - url: /_ah/mail/.+\n script: handle_incoming_email.php\n login: admin\n\n3. Implement code for the handlers you specified in your application code.\n\n You can read the MIME data from\n [php://input](https://php.net/manual/en/wrappers.php.php#wrappers.php.input) and parse the email\n content using [Mailparse](http://php.net/manual/en/book.mailparse.php)."]]