참고: PHP 5는 2024년 1월 30일 지원 종료되었습니다. 기존 PHP 5 애플리케이션을 계속 실행하고 트래픽을 받을 수 있습니다. 그러나 지원 종료 날짜 이후에는 해당 런타임을 사용하는 애플리케이션의 재배포를 App Engine에서 차단할 수 있습니다.
지원되는 최신 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/.+ 패턴은 모든 수신 이메일 주소와 일치합니다.