Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/wreyesus/Sencillo_Carrito_de_Compras_en_PHP/llms.txt

Use this file to discover all available pages before exploring further.

The YUME|TEC project sends two automated emails at key moments in the shopper’s journey: a welcome message when a new account is created, and a full order summary the moment the customer is redirected to PayPal for payment. Both emails are sent using the PHPMailer library, which is bundled directly in the project root as class.phpmailer.php and class.smtp.php — no Composer, no package manager, and no external dependencies. Two PHP pages use it: registro.php (welcome email) and final.php (order confirmation email).

Bundled PHPMailer

PHPMailer version 1.73 ships as two files in the repository root:
FilePurpose
class.phpmailer.phpCore mailer class — message construction, header building, and dispatch via mail(), sendmail, or SMTP.
class.smtp.phpSMTP transport layer, required automatically by class.phpmailer.php when IsSMTP() is called.
Both pages that send mail load the library with a direct require before any other logic runs:
require("class.phpmailer.php");
The bundled version defaults to PHP’s native mail() function ($mail->Mailer = "mail"). To switch to SMTP, call $mail->IsSMTP() and set the Host, SMTPAuth, Username, and Password properties before calling Send().

Welcome email (registro.php)

After inserting the new user row into the usuario table and establishing the login session, registro.php immediately sends a welcome email to the address the user provided during registration. The full mailer block from the source:
$saludo = "Muchas Gracias por registrarse en nuestra tienda";
$correo_empresa = "[email protected]";
$empresa = "Tu empresa";
$asunto = "Gracias Por Registrarse";
$mail = new PHPMailer();
$mail->Host = "la direccion de tu sitio web http://www.tusitio.com/";
$mail->From = $correo_empresa;
$mail->FromName = $empresa;
$mail->Subject = $asunto;
$mail->AddAddress($correo, "Bienvenido " . $nombre);
$mail->Body = $saludo;
$mail->AltBody = "Registro Exitoso";
$mail->Send();
The welcome email goes to the address the user submitted in the registration form ($correo = $_POST['correo']). The recipient display name is set to "Bienvenido " followed by the user’s first name. The AltBody field provides a plain-text fallback ("Registro Exitoso") for mail clients that do not render HTML. Before deploying, replace the placeholder values for Host, From, and FromName with the real credentials for your mail server or transactional email service.

Order confirmation email (final.php)

When the shopper submits their contact details on the checkout page, final.php reads $_SESSION['carrito'], builds a line-item summary, and sends it to two addresses simultaneously before auto-submitting the PayPal payment form.
$pedido = "Pedido de productos Yume-Tec. <br><br>";
$total = 0;
for ($i = 0; $i <= count($compras) - 1; $i++) {
    if ($compras[$i] != NULL) {
        $pedido .= $compras[$i]['nombre'] . " ***** " . $compras[$i]['precio']
                 . " x " . $compras[$i]['cantidad']
                 . " Total: " . $compras[$i]['precio'] * $compras[$i]['cantidad'] . " Dolares <br>";
        $total = $total + $compras[$i]['precio'] * $compras[$i]['cantidad'];
    }
}
$pedido .= "<br><br>Total: " . $total;
$mail->AddAddress($correo, "Compra a nombre " . $nombre);
$mail->AddAddress("[email protected]", "Copia de Pedido ");
$mail->Body = $pedido;
$mail->Send();
Two addresses receive every order:
  1. The customer — the email address collected from $_POST['email'] on the checkout form, with the display name set to "Compra a nombre " followed by their name.
  2. The store owner — a hardcoded address ([email protected]) that receives a copy of every order. This must be updated before going live.
NULL items (removed products) are skipped with the if ($compras[$i] != NULL) guard, so the email only lists the products the shopper actually intends to buy. The grand total appended at the bottom of the body matches the amount field sent to PayPal.

Configuring for production

The following values are hardcoded to placeholder or development values and must be changed before the store handles real orders:
Property / CallFileCurrent placeholderWhat to set
$mail->Hostregistro.php"la direccion de tu sitio web http://www.tusitio.com/"Your SMTP server hostname (e.g. smtp.mailgun.org)
$mail->Fromregistro.php"[email protected]"Your verified sender email address
$mail->FromNameregistro.php"Tu empresa"Your store or brand name
$mail->Hostfinal.php"http://programacionphp.liriosdesaron.net/"Your SMTP server hostname
$mail->Fromfinal.php"[email protected]"Your verified sender email address
$mail->AddAddress(...) store copyfinal.php"[email protected]"The email address where order copies should be delivered
For reliable transactional email delivery in production, use a dedicated sending service instead of your host’s default mail() function. Services like Mailgun, SendGrid, and Amazon SES provide authenticated SMTP endpoints, delivery dashboards, and bounce handling. Switch PHPMailer to SMTP mode by calling $mail->IsSMTP() and supplying the service’s Host, Username, and Password before calling $mail->Send().

Testing locally

Email sending will silently fail in most local development environments (XAMPP, WAMP, MAMP) because there is no SMTP server configured. PHPMailer::Send() returns false and sets $mail->ErrorInfo, but neither registro.php nor final.php check the return value or display an error message — the page will appear to work normally even though no email was sent. Use a local mail-capture tool such as MailHog or a cloud testing inbox like Mailtrap to intercept outgoing emails during development without delivering them to real addresses.

Build docs developers (and LLMs) love