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 asDocumentation 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.
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:| File | Purpose |
|---|---|
class.phpmailer.php | Core mailer class — message construction, header building, and dispatch via mail(), sendmail, or SMTP. |
class.smtp.php | SMTP transport layer, required automatically by class.phpmailer.php when IsSMTP() is called. |
require before any other logic runs:
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:
$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.
- 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. - The store owner — a hardcoded address (
[email protected]) that receives a copy of every order. This must be updated before going live.
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 / Call | File | Current placeholder | What to set |
|---|---|---|---|
$mail->Host | registro.php | "la direccion de tu sitio web http://www.tusitio.com/" | Your SMTP server hostname (e.g. smtp.mailgun.org) |
$mail->From | registro.php | "[email protected]" | Your verified sender email address |
$mail->FromName | registro.php | "Tu empresa" | Your store or brand name |
$mail->Host | final.php | "http://programacionphp.liriosdesaron.net/" | Your SMTP server hostname |
$mail->From | final.php | "[email protected]" | Your verified sender email address |
$mail->AddAddress(...) store copy | final.php | "[email protected]" | The email address where order copies should be delivered |
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.