Foros del Web » Programando para Internet » PHP »

Un script muy util

Estas en el tema de Un script muy util en el foro de PHP en Foros del Web. Hola amigos: He encontrado un script muy util para mandar mails. Solo necesitaria saber como agregar la opcion CCO. Como podria agregarla? Muchas gracias Ilda ...
  #1 (permalink)  
Antiguo 20/05/2008, 13:13
 
Fecha de Ingreso: junio-2001
Mensajes: 277
Antigüedad: 22 años, 10 meses
Puntos: 1
Un script muy util

Hola amigos:

He encontrado un script muy util para mandar mails. Solo necesitaria saber como agregar la opcion CCO.

Como podria agregarla?

Muchas gracias

Ilda


Este es el script:


<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Email anyone</title>
</head>

<body>
<p><font size="5"><b>Email</b></font></p>
<?php
if(@isset($_POST['submit'])) {
// require fields...look at the hidden field to change what's required
$required_fields = explode(",", $_POST['required']);

$error = 0;

foreach($required_fields as $fieldname) {
if ($_POST[$fieldname] == "") {
$error++;
}
}


if ($error == 0) {
if (strstr($_POST['to'], "@") and strstr($_POST['to'], ".")) {
if (strstr($_POST['from'], "@") and strstr($_POST['from'], ".")) {
// headers to be included in email
$headers .= "MIME-Version: 1.0\n";
// html header (delete the following row if you do not want html to show)
$headers .= "Content-type: text/html; charset=iso-8859-1\n";
// from header
$headers .= "From: $_POST[name] <$_POST[from]>";
// mail function
mail("$_POST[to]" , "$_POST[subject]", $_POST[message], $headers);

// success message
// if you receive a php error, make sure your server is set up to send email
print "<b><font size=2>Your email has been sent to $_POST[to] from $_POST[from]</font></b>";
exit;

}
} else {
$errormessage = "<b><font color=red>The email address you entered does not appear to be valid.</font><br></b>";
}


} else {
$errormessage = "<b><font color=red>You have left some required fields in the form blank. Please fill in the form completely.</font><br></b>";
}
}
?>
<form action="<? PHP_SELF; ?>" method="POST">
<? echo "$errormessage"; ?>
<p><font color="#FF0000">Everything is required. </font></p>
<p><font color="#000000">To: </font>
<font color="#000000">
<input name="to" type="text" id="to" size="30">
</font></p>
<p><font color="#000000">From (email): </font>
<font color="#000000">
<input name="from" type="text" id="from" size="30">
</font></p>
<p><font color="#000000">From (name):
<input name="name" type="text" id="name" size="30">
</font></p>
<p><font color="#000000">Subject
<input name="subject" type="text" id="subject" size="30">
</font></p>
<p><font color="#000000">Message <br>
HTML code is turned on.
<br>
<textarea name="message" cols="40" rows="6" id="message"></textarea>
</font></p>
<p>
<font color="#000000">
<input type="submit" value="Submit" name="submit">
</font> </p>
<input type="hidden" name="required" value="to,from,name,subject,message">
</form>
</body>
</html>
  #2 (permalink)  
Antiguo 21/05/2008, 12:27
AlvaroG
Invitado
 
Mensajes: n/a
Puntos:
Respuesta: Un script muy util

Tenés que usar una cabecera extra BCC (que es la versión inglesa de CCO) como esta

BCC: direccion1, direccion2, direccion3


Probalo


Saludos.
  #3 (permalink)  
Antiguo 22/05/2008, 15:16
 
Fecha de Ingreso: junio-2001
Mensajes: 277
Antigüedad: 22 años, 10 meses
Puntos: 1
Respuesta: Un script muy util

Gracias Alvlin

Pero es que no tengo mucha practica en esto. Podrias darme un ejemplo de como hacerlo?

Gracias

Ilda

Última edición por ilda; 22/05/2008 a las 15:50
  #4 (permalink)  
Antiguo 22/05/2008, 16:08
AlvaroG
Invitado
 
Mensajes: n/a
Puntos:
Respuesta: Un script muy util

Simplemente como prueba, agregá lo siguiente después de la línea
Código PHP:
$headers .= "From: $_POST[name] <$_POST[from]>"
Código PHP:
$headers .= "BCC: [email protected][email protected]"
Si no tenés 3 direcciones para probar (una que reciba el mensaje, y las otras dos que lo reciban como copia oculta), supongo que le podrás pedir a algún amigo o amiga que te ayude


Saludos.
  #5 (permalink)  
Antiguo 22/05/2008, 18:38
isra00
Invitado
 
Mensajes: n/a
Puntos:
Respuesta: Un script muy util

No olvides el salto de línea y retorno de carro entre cabecera y cabecera ("\r\n"):

Código PHP:
 $headers .= "\r\nBCC: [email protected][email protected]"
  #6 (permalink)  
Antiguo 29/05/2008, 13:01
 
Fecha de Ingreso: junio-2001
Mensajes: 277
Antigüedad: 22 años, 10 meses
Puntos: 1
Respuesta: Un script muy util

Hola amigos

Ya agregue la linea que me habeis sugerido y el script sigue funcionando, pero aun no aparece la opcion cco

Este es el codigo como me quedo. Existe algun otro paso que debe dar?

Gracias por la ayuda

Ilda

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Email anyone</title>
</head>

<body>
<p><font size="5"><b>Email</b></font></p>
<?php
if(@isset($_POST['submit'])) {
// require fields...look at the hidden field to change what's required
$required_fields = explode(",", $_POST['required']);

$error = 0;

foreach($required_fields as $fieldname) {
if ($_POST[$fieldname] == "") {
$error++;
}
}


if ($error == 0) {
if (strstr($_POST['to'], "@") and strstr($_POST['to'], ".")) {
if (strstr($_POST['from'], "@") and strstr($_POST['from'], ".")) {
// headers to be included in email
$headers .= "MIME-Version: 1.0\n";
// html header (delete the following row if you do not want html to show)
$headers .= "Content-type: text/html; charset=iso-8859-1\n";
// from header
$headers .= "From: $_POST[name] <$_POST[from]>";
$headers .= "\r\nBCC: [email protected], [email protected]";
// mail function
mail("$_POST[to]" , "$_POST[subject]", $_POST[message], $headers);

// success message
// if you receive a php error, make sure your server is set up to send email
print "<b><font size=2>Your email has been sent to $_POST[to] from $_POST[from]</font></b>";
exit;

}
} else {
$errormessage = "<b><font color=red>The email address you entered does not appear to be valid.</font><br></b>";
}


} else {
$errormessage = "<b><font color=red>You have left some required fields in the form blank. Please fill in the form completely.</font><br></b>";
}
}
?>
<form action="<? PHP_SELF; ?>" method="POST">
<? echo "$errormessage"; ?>
<p><font color="#FF0000">Everything is required. </font></p>
<p><font color="#000000">To: </font>
<font color="#000000">
<input name="to" type="text" id="to" size="30">
</font></p>
<p><font color="#000000">From (email): </font>
<font color="#000000">
<input name="from" type="text" id="from" size="30">
</font></p>
<p><font color="#000000">From (name):
<input name="name" type="text" id="name" size="30">
</font></p>
<p><font color="#000000">Subject
<input name="subject" type="text" id="subject" size="30">
</font></p>
<p><font color="#000000">Message <br>
HTML code is turned on.
<br>
<textarea name="message" cols="40" rows="6" id="message"></textarea>
</font></p>
<p>
<font color="#000000">
<input type="submit" value="Submit" name="submit">
</font> </p>
<input type="hidden" name="required" value="to,from,name,subject,message">
</form>
</body>
</html>
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 15:02.