Así
- Dispone de un servidor
- se obtiene correos electrónicos
- que desea guardarlos int una base de datos MySQL
Cpanel config
- ir al correo electrónico cpnal promotor de
- agregue uno nuevo
- redireccione a PATH - > /home/your_user/whatever/php.script.php
script php (puede que tenga que cambiar la ruta "/ usr/bin/php -q" dependiendo de la configuración del servidor)
#!/usr/bin/php -q
<?php
chdir(dirname(__FILE__));
$fd = fopen("php://stdin", "r");
$email = "";
while (!feof($fd)) {
$email .= fread($fd, 1024);
}
fclose($fd);
if(strlen($email)<1) {
die();
}
// handle email
$lines = explode("\n", $email);
// empty vars
$from = "";
$to="";
$subject = "";
$headers = "";
$message = "";
$splittingheaders = true;
for ($i=0; $i < count($lines); $i++) {
if ($splittingheaders) {
// this is a header
$headers .= $lines[$i]."\n";
// look out for special headers
if (preg_match("/^Subject: (.*)/", $lines[$i], $matches)) {
$subject = $matches[1];
}
if (preg_match("/^From: (.*)/", $lines[$i], $matches)) {
$from = $matches[1];
}
if (preg_match("/^To: (.*)/", $lines[$i], $matches)) {
$to = $matches[1];
}
} else {
// not a header, but message
$message .= $lines[$i]."\n";
}
if (trim($lines[$i])=="") {
// empty line, header section has ended
$splittingheaders = false;
}
}
Obras en alojamiento compartido también! :)
Todo lo que necesita agregar es la inserción mysql y usar las variables definidas anteriormente. ¿Sabes cómo usar una base de datos mysql de php? ¿O necesitas ayuda con eso también?
Este es un tipo de servicio, no creo que esto sea posible en alojamiento compartido, necesitará más privilegios. – Youssef
Esta es una pregunta frecuente intenta buscar SO para las muchas respuestas anteriores. – symcbean