Organiza tus páginas con colecciones
Guarda y categoriza el contenido según tus preferencias.
En esta guía, se describe cómo usar la API de Mail para enviar correos electrónicos.
Antes de comenzar
Registra los correos electrónicos de tus remitentes como remitentes autorizados. Para obtener más información, consulta quién puede enviar correos electrónicos.
Envía correos electrónicos
En PHP 7/8, la función de correo electrónico de App Engine ya no se sobrecarga de forma predeterminada, y
se debe habilitar de forma explícita. Este nuevo comportamiento te permite adaptar la función de correo electrónico
para que se adapte mejor a tus necesidades. Este cambio también te permite tener visibilidad sobre
qué implementación se está usando actualmente para todas las llamadas a funciones de correo electrónico.
Si prefieres usar la función mail() nativa de PHP para enviar correos electrónicos con la API de Mail de App Engine, puedes habilitarla en tu archivo php.ini de la siguiente manera:
Otra alternativa es hacer llamadas directas a la API de correo electrónico de la siguiente manera:
// 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';
[[["Fácil de comprender","easyToUnderstand","thumb-up"],["Resolvió mi problema","solvedMyProblem","thumb-up"],["Otro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Información o código de muestra incorrectos","incorrectInformationOrSampleCode","thumb-down"],["Faltan la información o los ejemplos que necesito","missingTheInformationSamplesINeed","thumb-down"],["Problema de traducción","translationIssue","thumb-down"],["Otro","otherDown","thumb-down"]],["Última actualización: 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"]]