Hello, I have a doubt. I am trying to send a page in html via mail, by executing a function in php, instead of directly placing the html inside the function.
To see a clear example of what I need would be something like this: Button assigned to the function of sending mail that the body of that mail has the content, including the css, of an html page.
I simply want to remove the html from the message and put a kind of reference to a website, take its content from it and put it in the email
$para = '[email protected]';
// Asunto
$titulo = 'NUEVO PEDIDO';
// Cuerpo o mensaje
$mensaje = '
<html>
<head>
<title>Hay un nuevo pedido</title>
</head>
<body>
<h2>Hay un nuevo pedido</h2>
<a href="https://www.miweb.com/pedidos/last.php">CLICK AQUI</a>
</body>
</html>
';
$cabeceras = 'MIME-Version: 1.0' . "\r\n";
$cabeceras .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$cabeceras .= 'From: Recordatorio <[email protected]>' . "\r\n";
mail($para, $titulo, $mensaje, $cabeceras);
Since the content you want to include is on the same domain, it would be best to use the
include()
PHP function, which exists for that purpose. Then, withob_get_contents()
you can save the content of the included file in a variable to send it in the email.The code would be like this:
Email sending script
last.php