Cómo evitar el correo spam () en PHP
- diyath
- Newbie


- Registrado: Oct 13, 2010
- Mensajes: 5
- Status: Offline
Puedo usar esta clase enviar correo electrónico, pero se han ido como spam
PHP Código: [ Select ]
<?php
/***
Email addresses can validate using email_validation(...) method.
This class is use to send mails to valid email address(es)
by calling methods as following order,
1) set_header(.....)
2) set_body(...)
3) send_mail(.....)
***/
class GenerateMails{
private $headers = array();
private $recipients;
private $contenttype;
private $subject;
private $email_msg;
private $hdr;
public $msg;
/* This function use for validate email address(es).
para :
$email_addrses = This can be list of email addresses seperated by commas
or email addresses array
return :
true/false
*/
public function email_validation($email_addrses)
{
$validate = true;
if(!is_array($email_addrses))
{
$email_arry = explode(',',$email_addrses);
$validate=$this->chk_email_arry($email_arry);
}
else
{
$validate=$this->chk_email_arry($email_addrses);
}
return $validate;
}
/* This function use for generate msg for email address(es)
para :
$email_arry = Email array
return :
true/false
*/
private function chk_email_arry($email_arry)
{
$rtn_val=true;
foreach($email_arry as $val)
{
if(!filter_var($val,FILTER_VALIDATE_EMAIL))
{
$this->msg .= $val.' - Invalid Email Address.<br />';
$rtn_val=false;
}
}
return $rtn_val;
}
/* This function use to set sender email & name
para :
$email = sender email
$name = sender name
*/
private function from($email,$name)
{
@ini_set('sendmail_from','test');
$this->headers[] = 'From: '.$email.' <'.$name.'>';
}
/* This function use to set reply to email & name
para :
$email = Reply email
$name = Reply name
*/
private function reply_to($rplyto_email,$rplyto_name)
{
$this->headers[] = 'Reply-To: '.$rplyto_email.' <'.$rplyto_name.'>';
}
/* This function is use for add reciepients.
para :
$recipient_list = recipient list should separate by comma.
*/
private function add_recipient($recipient_list)
{
$this->recipients =$recipient_list;
}
/* This function is use for add CC.
para :
$cc_address_list = cc address list should separate by comma.
*/
private function set_cc($cc_address_list)
{
$this->headers[] = "CC: ".$cc_address_list;
}
/* This function is use for add BCC.
para :
$bcc_address_list = BCC address list should separate by comma.
*/
private function set_bcc($bcc_address_list)
{
$this->headers[] = "BCC: ".$bcc_address_list;
}
/* This function use to set header values.
para :
$header_type = normal - without attachment
attachment - with attachment
$ishtml = true - content type is HTML
false - content is plain text
*/
public function mail_header($header_type, $ishtml = true)
{
$this->headers[] = "MIME-Version: 1.0";
switch($header_type)
{
case "normal":
if ($ishtml) {
$this->contenttype = "text/html";
} else {
$this->contenttype = "text/plain";
}
$this->headers[] = "Content-type: ".$this->contenttype."; charset=UTF-8";
break;
case "attachment":
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
$this->headers[] = "Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary}\"";
break;
}
}
/* This function use to set priorities
*/
private function priority()
{
$this->headers[] = "X-Priority: 3";
$this->headers[] = "X-Mailer: php";
}
/* This function use to set mail subject.
*/
private function set_subject($subject)
{
$this->subject = $subject;
}
/* This function use to set mail attachmant(s)
para :
$attfile = file name(s) array
*/
private function set_attachment($attfile)
{
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
// preparing attachments
$file = fopen($attfile,"rb");
$data = fread($file,filesize($attfile));
fclose($file);
$data = chunk_split(base64_encode($data));
$message = "Content-Type: {\"application/octet-stream\"};\n" . " name=\"$attfile\"\n" .
"Content-Disposition: attachment;\n" . " filename=\"$attfile\"\n" .
"Content-Transfer-Encoding: base64\n\n" . $data . "\n\n";
$message .= "--{$mime_boundary}\n";
return $message;
}
/* This function use to set mail header
para :
$header_type = normal - without attachment
attachment - with attachment
$ishtml = true - content type is HTML
false - content is plain text
$from_email = from email address
$from_name = from name
$recipient_list = recipient email(s) seperated by commas
$cc_address_list = CC email(s) seperated by commas
$bcc_address_list = BCC email(s) seperated by commas
$subject = email subject
*/
public function set_header($header_type, $ishtml=true, $from_email, $from_name, $rplyto_email, $rplyto_name,$recipient_list, $cc_address_list, $bcc_address_list, $subject)
{
$this->mail_header($header_type, $ishtml=true);
$this->priority();
$this->from($from_email,$from_name);
$this->reply_to($rplyto_email,$rplyto_name);
$this->add_recipient($recipient_list);
$this->set_cc($cc_address_list);
$this->set_bcc($bcc_address_list);
$this->set_subject($subject);
}
/* This function use to set mail body
para :
$email_msg = massege
$email_msg_type = normal - without attachment
attachment - with attachment
$attfile = file name(s) array
*/
public function set_body($email_msg,$email_msg_type,$attfile)
{
switch($email_msg_type)
{
case "normal":
$this->email_msg = wordwrap($email_msg,70);
break;
case "attachment":
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
$this->email_msg = "This is a multi-part message in MIME format.\n\n" . "--{$mime_boundary}\n" . "Content-Type: text/html; charset=\"iso-8859-1\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . $email_msg . "\n\n";
$this->email_msg .= "--{$mime_boundary}\n";
if(is_array($attfile))
{
for($x=0;$x<count($attfile);$x++)
{
if(file_exists($attfile[$x]))
{
$this->email_msg .= $this->set_attachment($attfile[$x]);
}
else
{
$this->email_msg .= ' No Data found for the file '.$attfile[$x]."--{$mime_boundary}\n";
}
}
}
/* else
{
$this->email_msg = $this->set_attachment($attfile);
}
*/
break;
}
$this->email_msg = wordwrap($this->email_msg,70);
}
/* This function use to send mail
return :
treu/false
*/
public function send_mail()
{
$this->hdr = implode("\r\n",$this->headers);
unset($this->headers);
return mail($this->recipients, $this->subject, $this->email_msg, $this->hdr);
}
}
?>
/***
Email addresses can validate using email_validation(...) method.
This class is use to send mails to valid email address(es)
by calling methods as following order,
1) set_header(.....)
2) set_body(...)
3) send_mail(.....)
***/
class GenerateMails{
private $headers = array();
private $recipients;
private $contenttype;
private $subject;
private $email_msg;
private $hdr;
public $msg;
/* This function use for validate email address(es).
para :
$email_addrses = This can be list of email addresses seperated by commas
or email addresses array
return :
true/false
*/
public function email_validation($email_addrses)
{
$validate = true;
if(!is_array($email_addrses))
{
$email_arry = explode(',',$email_addrses);
$validate=$this->chk_email_arry($email_arry);
}
else
{
$validate=$this->chk_email_arry($email_addrses);
}
return $validate;
}
/* This function use for generate msg for email address(es)
para :
$email_arry = Email array
return :
true/false
*/
private function chk_email_arry($email_arry)
{
$rtn_val=true;
foreach($email_arry as $val)
{
if(!filter_var($val,FILTER_VALIDATE_EMAIL))
{
$this->msg .= $val.' - Invalid Email Address.<br />';
$rtn_val=false;
}
}
return $rtn_val;
}
/* This function use to set sender email & name
para :
$email = sender email
$name = sender name
*/
private function from($email,$name)
{
@ini_set('sendmail_from','test');
$this->headers[] = 'From: '.$email.' <'.$name.'>';
}
/* This function use to set reply to email & name
para :
$email = Reply email
$name = Reply name
*/
private function reply_to($rplyto_email,$rplyto_name)
{
$this->headers[] = 'Reply-To: '.$rplyto_email.' <'.$rplyto_name.'>';
}
/* This function is use for add reciepients.
para :
$recipient_list = recipient list should separate by comma.
*/
private function add_recipient($recipient_list)
{
$this->recipients =$recipient_list;
}
/* This function is use for add CC.
para :
$cc_address_list = cc address list should separate by comma.
*/
private function set_cc($cc_address_list)
{
$this->headers[] = "CC: ".$cc_address_list;
}
/* This function is use for add BCC.
para :
$bcc_address_list = BCC address list should separate by comma.
*/
private function set_bcc($bcc_address_list)
{
$this->headers[] = "BCC: ".$bcc_address_list;
}
/* This function use to set header values.
para :
$header_type = normal - without attachment
attachment - with attachment
$ishtml = true - content type is HTML
false - content is plain text
*/
public function mail_header($header_type, $ishtml = true)
{
$this->headers[] = "MIME-Version: 1.0";
switch($header_type)
{
case "normal":
if ($ishtml) {
$this->contenttype = "text/html";
} else {
$this->contenttype = "text/plain";
}
$this->headers[] = "Content-type: ".$this->contenttype."; charset=UTF-8";
break;
case "attachment":
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
$this->headers[] = "Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary}\"";
break;
}
}
/* This function use to set priorities
*/
private function priority()
{
$this->headers[] = "X-Priority: 3";
$this->headers[] = "X-Mailer: php";
}
/* This function use to set mail subject.
*/
private function set_subject($subject)
{
$this->subject = $subject;
}
/* This function use to set mail attachmant(s)
para :
$attfile = file name(s) array
*/
private function set_attachment($attfile)
{
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
// preparing attachments
$file = fopen($attfile,"rb");
$data = fread($file,filesize($attfile));
fclose($file);
$data = chunk_split(base64_encode($data));
$message = "Content-Type: {\"application/octet-stream\"};\n" . " name=\"$attfile\"\n" .
"Content-Disposition: attachment;\n" . " filename=\"$attfile\"\n" .
"Content-Transfer-Encoding: base64\n\n" . $data . "\n\n";
$message .= "--{$mime_boundary}\n";
return $message;
}
/* This function use to set mail header
para :
$header_type = normal - without attachment
attachment - with attachment
$ishtml = true - content type is HTML
false - content is plain text
$from_email = from email address
$from_name = from name
$recipient_list = recipient email(s) seperated by commas
$cc_address_list = CC email(s) seperated by commas
$bcc_address_list = BCC email(s) seperated by commas
$subject = email subject
*/
public function set_header($header_type, $ishtml=true, $from_email, $from_name, $rplyto_email, $rplyto_name,$recipient_list, $cc_address_list, $bcc_address_list, $subject)
{
$this->mail_header($header_type, $ishtml=true);
$this->priority();
$this->from($from_email,$from_name);
$this->reply_to($rplyto_email,$rplyto_name);
$this->add_recipient($recipient_list);
$this->set_cc($cc_address_list);
$this->set_bcc($bcc_address_list);
$this->set_subject($subject);
}
/* This function use to set mail body
para :
$email_msg = massege
$email_msg_type = normal - without attachment
attachment - with attachment
$attfile = file name(s) array
*/
public function set_body($email_msg,$email_msg_type,$attfile)
{
switch($email_msg_type)
{
case "normal":
$this->email_msg = wordwrap($email_msg,70);
break;
case "attachment":
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
$this->email_msg = "This is a multi-part message in MIME format.\n\n" . "--{$mime_boundary}\n" . "Content-Type: text/html; charset=\"iso-8859-1\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . $email_msg . "\n\n";
$this->email_msg .= "--{$mime_boundary}\n";
if(is_array($attfile))
{
for($x=0;$x<count($attfile);$x++)
{
if(file_exists($attfile[$x]))
{
$this->email_msg .= $this->set_attachment($attfile[$x]);
}
else
{
$this->email_msg .= ' No Data found for the file '.$attfile[$x]."--{$mime_boundary}\n";
}
}
}
/* else
{
$this->email_msg = $this->set_attachment($attfile);
}
*/
break;
}
$this->email_msg = wordwrap($this->email_msg,70);
}
/* This function use to send mail
return :
treu/false
*/
public function send_mail()
{
$this->hdr = implode("\r\n",$this->headers);
unset($this->headers);
return mail($this->recipients, $this->subject, $this->email_msg, $this->hdr);
}
}
?>
- <?php
- /***
- Email addresses can validate using email_validation(...) method.
- This class is use to send mails to valid email address(es)
- by calling methods as following order,
- 1) set_header(.....)
- 2) set_body(...)
- 3) send_mail(.....)
- ***/
- class GenerateMails{
- private $headers = array();
- private $recipients;
- private $contenttype;
- private $subject;
- private $email_msg;
- private $hdr;
- public $msg;
- /* This function use for validate email address(es).
- para :
- $email_addrses = This can be list of email addresses seperated by commas
- or email addresses array
- return :
- true/false
- */
- public function email_validation($email_addrses)
- {
- $validate = true;
- if(!is_array($email_addrses))
- {
- $email_arry = explode(',',$email_addrses);
- $validate=$this->chk_email_arry($email_arry);
- }
- else
- {
- $validate=$this->chk_email_arry($email_addrses);
- }
- return $validate;
- }
- /* This function use for generate msg for email address(es)
- para :
- $email_arry = Email array
- return :
- true/false
- */
- private function chk_email_arry($email_arry)
- {
- $rtn_val=true;
- foreach($email_arry as $val)
- {
- if(!filter_var($val,FILTER_VALIDATE_EMAIL))
- {
- $this->msg .= $val.' - Invalid Email Address.<br />';
- $rtn_val=false;
- }
- }
- return $rtn_val;
- }
- /* This function use to set sender email & name
- para :
- $email = sender email
- $name = sender name
- */
- private function from($email,$name)
- {
- @ini_set('sendmail_from','test');
- $this->headers[] = 'From: '.$email.' <'.$name.'>';
- }
- /* This function use to set reply to email & name
- para :
- $email = Reply email
- $name = Reply name
- */
- private function reply_to($rplyto_email,$rplyto_name)
- {
- $this->headers[] = 'Reply-To: '.$rplyto_email.' <'.$rplyto_name.'>';
- }
- /* This function is use for add reciepients.
- para :
- $recipient_list = recipient list should separate by comma.
- */
- private function add_recipient($recipient_list)
- {
- $this->recipients =$recipient_list;
- }
- /* This function is use for add CC.
- para :
- $cc_address_list = cc address list should separate by comma.
- */
- private function set_cc($cc_address_list)
- {
- $this->headers[] = "CC: ".$cc_address_list;
- }
- /* This function is use for add BCC.
- para :
- $bcc_address_list = BCC address list should separate by comma.
- */
- private function set_bcc($bcc_address_list)
- {
- $this->headers[] = "BCC: ".$bcc_address_list;
- }
- /* This function use to set header values.
- para :
- $header_type = normal - without attachment
- attachment - with attachment
- $ishtml = true - content type is HTML
- false - content is plain text
- */
- public function mail_header($header_type, $ishtml = true)
- {
- $this->headers[] = "MIME-Version: 1.0";
- switch($header_type)
- {
- case "normal":
- if ($ishtml) {
- $this->contenttype = "text/html";
- } else {
- $this->contenttype = "text/plain";
- }
- $this->headers[] = "Content-type: ".$this->contenttype."; charset=UTF-8";
- break;
- case "attachment":
- $semi_rand = md5(time());
- $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
- $this->headers[] = "Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary}\"";
- break;
- }
- }
- /* This function use to set priorities
- */
- private function priority()
- {
- $this->headers[] = "X-Priority: 3";
- $this->headers[] = "X-Mailer: php";
- }
- /* This function use to set mail subject.
- */
- private function set_subject($subject)
- {
- $this->subject = $subject;
- }
- /* This function use to set mail attachmant(s)
- para :
- $attfile = file name(s) array
- */
- private function set_attachment($attfile)
- {
- $semi_rand = md5(time());
- $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
- // preparing attachments
- $file = fopen($attfile,"rb");
- $data = fread($file,filesize($attfile));
- fclose($file);
- $data = chunk_split(base64_encode($data));
- $message = "Content-Type: {\"application/octet-stream\"};\n" . " name=\"$attfile\"\n" .
- "Content-Disposition: attachment;\n" . " filename=\"$attfile\"\n" .
- "Content-Transfer-Encoding: base64\n\n" . $data . "\n\n";
- $message .= "--{$mime_boundary}\n";
- return $message;
- }
- /* This function use to set mail header
- para :
- $header_type = normal - without attachment
- attachment - with attachment
- $ishtml = true - content type is HTML
- false - content is plain text
- $from_email = from email address
- $from_name = from name
- $recipient_list = recipient email(s) seperated by commas
- $cc_address_list = CC email(s) seperated by commas
- $bcc_address_list = BCC email(s) seperated by commas
- $subject = email subject
- */
- public function set_header($header_type, $ishtml=true, $from_email, $from_name, $rplyto_email, $rplyto_name,$recipient_list, $cc_address_list, $bcc_address_list, $subject)
- {
- $this->mail_header($header_type, $ishtml=true);
- $this->priority();
- $this->from($from_email,$from_name);
- $this->reply_to($rplyto_email,$rplyto_name);
- $this->add_recipient($recipient_list);
- $this->set_cc($cc_address_list);
- $this->set_bcc($bcc_address_list);
- $this->set_subject($subject);
- }
- /* This function use to set mail body
- para :
- $email_msg = massege
- $email_msg_type = normal - without attachment
- attachment - with attachment
- $attfile = file name(s) array
- */
- public function set_body($email_msg,$email_msg_type,$attfile)
- {
- switch($email_msg_type)
- {
- case "normal":
- $this->email_msg = wordwrap($email_msg,70);
- break;
- case "attachment":
- $semi_rand = md5(time());
- $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
- $this->email_msg = "This is a multi-part message in MIME format.\n\n" . "--{$mime_boundary}\n" . "Content-Type: text/html; charset=\"iso-8859-1\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . $email_msg . "\n\n";
- $this->email_msg .= "--{$mime_boundary}\n";
- if(is_array($attfile))
- {
- for($x=0;$x<count($attfile);$x++)
- {
- if(file_exists($attfile[$x]))
- {
- $this->email_msg .= $this->set_attachment($attfile[$x]);
- }
- else
- {
- $this->email_msg .= ' No Data found for the file '.$attfile[$x]."--{$mime_boundary}\n";
- }
- }
- }
- /* else
- {
- $this->email_msg = $this->set_attachment($attfile);
- }
- */
- break;
- }
- $this->email_msg = wordwrap($this->email_msg,70);
- }
- /* This function use to send mail
- return :
- treu/false
- */
- public function send_mail()
- {
- $this->hdr = implode("\r\n",$this->headers);
- unset($this->headers);
- return mail($this->recipients, $this->subject, $this->email_msg, $this->hdr);
- }
- }
- ?>
Moderator Remark: added [code] tags
- Anonymous
- Bot


- Registrado: 25 Feb 2008
- Mensajes: ?
- Loc: Ozzuland
- Status: Online
Octubre 22nd, 2010, 10:29 pm
- Bigwebmaster
- Site Admin


- Registrado: Dic 20, 2002
- Mensajes: 8925
- Loc: Seattle, WA & Phoenix, AZ
- Status: Offline
Cuando dices que los correos son "ido como spam", lo que significa que el correo electrónico no es aún capaz de ser enviado, ya que vuelve con un error? ¿O es que el correo electrónico se envían a su destino, pero el correo electrónico se muestra en la carpeta de spam o de distribución masiva? ¿Podría ser más específico a qué se refiere?
Ozzu Hosting - Want your website on a fast server like Ozzu?
- diyath
- Newbie


- Registrado: Oct 13, 2010
- Mensajes: 5
- Status: Offline
- SpooF
- ٩๏̯͡๏۶


- Registrado: May 22, 2004
- Mensajes: 3415
- Loc: Richland, WA
- Status: Offline
Eso podría ser un par de cosas.
Lo primero que puede hacer es asegurarse de que su envío de las cabeceras adecuadas, junto con su correo electrónico. Lo siguiente sería comprobar para ver si su servidor IP ha sido negro en la lista.
http://whatismyipaddress.com/blacklist-check
Lo primero que puede hacer es asegurarse de que su envío de las cabeceras adecuadas, junto con su correo electrónico. Lo siguiente sería comprobar para ver si su servidor IP ha sido negro en la lista.
http://whatismyipaddress.com/blacklist-check
#define NULL (::rand() % 2)
- Bigwebmaster
- Site Admin


- Registrado: Dic 20, 2002
- Mensajes: 8925
- Loc: Seattle, WA & Phoenix, AZ
- Status: Offline
Para el e-mail a su destino en el que está apareciendo como spam, yo sugeriría mirar los encabezados de correo electrónico no para ver si algo se destaca, como no las comprobaciones SPF, o cualquier otras etiquetas que podría indicar por qué su ser etiquetado como spam. También me gustaría ver todas las direcciones IP en los encabezados, además de su propia para ver si están en listas negras como falsos mencionados. A veces, cuando se envía por e-mail a cabo pasan por un servidor SMTP que es la lista negra por lo que me gustaría ver más direcciones IP que sólo la suya.
Ozzu Hosting - Want your website on a fast server like Ozzu?
Página 1 de 1
Para responder a este tema que necesita para ingresar o registrarse. Es gratis.
Publicar Información
- Total de mensajes en este tema: 5 mensajes
- Usuarios navegando por este Foro: No hay usuarios registrados visitando el Foro y 223 invitados
- No puede abrir nuevos temas en este Foro
- No puede responder a temas en este Foro
- No puede editar sus mensajes en este Foro
- No puede borrar sus mensajes en este Foro
- No puede enviar adjuntos en este Foro
