Ver Mensaje Individual
  #2 (permalink)  
Antiguo 01/07/2009, 13:09
Jhonjhon_123
 
Fecha de Ingreso: enero-2009
Mensajes: 100
Antigüedad: 16 años, 1 mes
Puntos: 1
Respuesta: Envio a mail con php

Este es un codigo mio:

Código PHP:
<?php
function form_correo($error)
{

echo 
'

<!-- INICIO Form correo -->

<table border="0" style="float: right" cellpadding="0" cellspacing="0" width="78%">'
;

if(
$error == "1")
    {
    
error_correo();
    }
elseif(
$error == "0")
    {
    
bien_correo();
    }
elseif(
$error == "")
    {
    echo 
'<br>';
    }

echo 
'
    <form action="tupagina.php" method="post">
    <table class="tborder" border="0" align="center" cellpadding="6" cellspacing="1" width="auto">

    <tr>
        <td class="titulo" colspan="2" align="center">Enviar Correo</td>
    </tr>
    
    <td class="panelsurround" align="center">
            <div class="panel">
                <table align="center" border="0" cellpadding="6" cellspacing="1" width="100%">

                    <tr>
                        <td><label for="de" class="fuentesmall">De: </label></td>
                        <td><input class="textbox" type="text" name="de" id="de" size="33"><input type="hidden" name="pase" value="si"></td>
                    </tr>

                    <tr>
                        <td><label for="para" class="fuentesmall">Para: </td>
                        <td><input class="textbox" type="text" name="para" id="para" size="33"></td>
                    </tr>

                    <tr>
                        <td><label for="responderA" class="fuentesmall">Responder A: </label></td>
                        <td><input class="textbox" type="text" name="responderA" id="responderA" size="33"></td>
                    </tr>

                    <tr>
                        <td><label for="asunto" class="fuentesmall">Asunto: </label></td>
                        <td><input class="textbox" type="text" name="asunto" id="asunto" size="33"></td>
                    </tr>
                    
                    <tr>
                        <td><label for="mensaje" class="fuentesmall">Mensaje: </label></td>
                        <td><textarea class="textbox" name="mensaje" id="mensaje" cols="31" rows="6"></textarea></td>
                    </tr>

                    <tr>
                        <td align="center" colspan="2"><input class="boton" type="submit" value="Enviar Correo"></td>
                    </tr>

                </table>
            </div>
        </td>
        
    </table>
    </form>
    
</table>

<!-- FIN Form correo -->

'
;
}

function 
error_correo()
{
echo 
'

<!-- INICIO Form correo ERROR -->

<table class="tborder" border="0" align="center" cellpadding="5" cellspacing="1" width="auto">

    <td align="center" class="titulo">
        Error, Posibles Causas
    </td>
    
    <tr>
        <td align="center" class="panel">
            <span class="fuentesmall_error">
                Debes rellenar todos los campos.
            </span>
        </td>
    </tr>

</table>

<br>

<!-- FIN Form correo ERROR -->

'
;
}

function 
bien_correo()
{
echo 
'

<!-- INICIO Form correo BIEN -->

<table class="tborder" border="0" align="center" cellpadding="5" cellspacing="1" width="auto">
    
    <td align="center" class="titulo">
        Correcto
    </td>
    
    <tr>
        <td align="center" class="panel">
            <span class="fuentesmall_bien">
                Mensaje enviado correctamente.
            </span>
        </td>
    </tr>

</table>

<br>

<!-- FIN Form correo ERROR -->

'
;
}

session_start();
if(
$_SESSION['usuario'] != "")
    {
    if(
$_POST['pase'] == "si")
        {
        
$para      $_POST['para'];
        
$asunto    $_POST['asunto'];
        
$mensaje   $_POST['mensaje'];
        
$de        $_POST['de'];
        
$responderA$_POST['responderA'];
        
$cabeceras 'From: '.$de."\r\n".
        
'Reply-To: '.$responderA;
        if(empty(
$para))
            {
            
$para="";
            }
        if(empty(
$para))
            {
            
$asunto="";
            }
        if(empty(
$para))
            {
            
$mensaje="";
            }
        if(empty(
$para))
            {
            
$de="";
            }
        if(empty(
$para))
            {
            
$responderA="";
            }
            
        if((
$para != "")and($asunto != "")and($mensaje != "")and($de != "")and($responderA != ""))
            {
            
mail($para$asunto$mensaje$cabeceras) or die ("Error: Mensaje no enviado");
            
form_correo("0");
            }
        else
            {
            
form_correo("1");
            }
        }
    else
        {
        
form_correo("");
        }
    }
?>
Funciona a la perfeccion!!!

Espero te ayude!!!