Cerrar Bienvenido
Cerrar Registrate

Ya somos 1.501.994 Forros navegando...

933 usuarios conectados | 1.501.994 forros | 367.333 temas | 4.381.467 mensajes | seremos forros, pero somos una bocha

Envío de mail con php en el foro de Programación:


Necesito me ayuden con el siguiente tema, tengo el siguiente archivo que supongo es el encargado en enviar los mails a los usuarios, pero no se donde debo hacer referencia del smtp de mi servidor para direccionar los emails, puesto que en el scrip no tengo ni un archivo con la función $mail <?php /* * cPHPezMail Version 1.0 (2004-04-12 03:00 pm +7 GMT) * COPYRIGHT 2004 CHARIN NAWARITLOHA. * Contact: Solo los usuarios registrados pueden ver los links. ¡Registrate ahora, es gratis! */ class cPHPezMail { var $aHeader; var $aMessage; var $aPOSTFileAttach; var $aLocalFileAttach; var $sFrom; var $aTo; var ...

 
LinkBack Herramientas Buscar en este tema
Viejo 24.10.09, 12:34
Necesito me ayuden con el siguiente tema, tengo el siguiente archivo que supongo es el encargado en enviar los mails a los usuarios, pero no se donde debo hacer referencia del smtp de mi servidor para direccionar los emails, puesto que en el scrip no tengo ni un archivo con la función $mail

<?php
/*
* cPHPezMail Version 1.0 (2004-04-12 03:00 pm +7 GMT)
* COPYRIGHT 2004 CHARIN NAWARITLOHA.
* Contact: Solo los usuarios registrados pueden ver los links. ¡Registrate ahora, es gratis!
*/
class cPHPezMail
{
var $aHeader;
var $aMessage;
var $aPOSTFileAttach;
var $aLocalFileAttach;
var $sFrom;
var $aTo;
var $sMimeBoundary;
var $sAltBoundary;
var $sBodyText;
var $sBodyHTML;
var $sSubject;
var $sCharset;
var $nEncoding;
var $sTempFileName;
var $aMimeType;
var $sDefaultMimeType;

function cPHPezMail()
{
$this->aLocalFileAttach = array();
$this->aPOSTFileAttach = array();
$this->aHeader = array();
$this->aMessage = array();
$this->sMimeBoundary = '==Multipart_Boundary_X'. md5(time()) .'X';
$this->sAltBoundary = '==Alternative_Boundary_X'. md5(time()) .'X';
$this->aTo = array();
$this->aCc = array();
$this->aCci = array();
$this->aBcc = array();
$this->sFrom = '';
$this->sBodyHTML = '';
$this->sBodyText = '';
$this->sSubject = '';
$this->sCharset = 'iso-8859-1';
$this->nEncoding = 7;
$this->sTempFileName = './upload_temp/' . md5(time()) . '.tmp';
$this->sDefaultMimeType = 'application/octet-stream';
$this->aMimeType = array (
'ai' => 'application/postscript',
'aif' => 'audio/x-aiff',
'aifc' => 'audio/x-aiff',
'aiff' => 'audio/x-aiff',
'asc' => 'text/plain',
'au' => 'audio/basic',
'avi' => 'video/x-msvideo',
'bcpio' => 'application/x-bcpio',
'bin' => 'application/octet-stream',
'bmp' => 'image/bmp',
'cdf' => 'application/x-netcdf',
'cgm' => 'image/cgm',
'class' => 'application/octet-stream',
'cpio' => 'application/x-cpio',
'cpt' => 'application/mac-compactpro',
'csh' => 'application/x-csh',
'css' => 'text/css',
'dcr' => 'application/x-director',
'dir' => 'application/x-director',
'djv' => 'image/vnd.djvu',
'djvu' => 'image/vnd.djvu',
'dll' => 'application/octet-stream',
'dms' => 'application/octet-stream',
'doc' => 'application/msword',
'dtd' => 'application/xml-dtd',
'dvi' => 'application/x-dvi',
'dxr' => 'application/x-director',
'eps' => 'application/postscript',
'etx' => 'text/x-setext',
'exe' => 'application/octet-stream',
'ez' => 'application/andrew-inset',
'gif' => 'image/gif',
'gram' => 'application/srgs',
'grxml' => 'application/srgs+xml',
'gtar' => 'application/x-gtar',
'gzip' => 'application/x-gzip',
'hdf' => 'application/x-hdf',
'hqx' => 'application/mac-binhex40',
'htm' => 'text/html',
'html' => 'text/html',
'ice' => 'x-conference/x-cooltalk',
'ico' => 'image/x-icon',
'ics' => 'text/calendar',
'ief' => 'image/ief',
'ifb' => 'text/calendar',
'iges' => 'model/iges',
'igs' => 'model/iges',
'jpe' => 'image/jpeg',
'jpeg' => 'image/jpeg',
'jpg' => 'image/jpeg',
'js' => 'application/x-javascript',
'kar' => 'audio/midi',
'latex' => 'application/x-latex',
'lha' => 'application/octet-stream',
'lzh' => 'application/octet-stream',
'm3u' => 'audio/x-mpegurl',
'man' => 'application/x-troff-man',
'mathml' => 'application/mathml+xml',
'me' => 'application/x-troff-me',
'mesh' => 'model/mesh',
'mid' => 'audio/midi',
'midi' => 'audio/midi',
'mov' => 'video/quicktime',
'movie' => 'video/x-sgi-movie',
'mp2' => 'audio/mpeg',
'mp3' => 'audio/mpeg',
'mpe' => 'video/mpeg',
'mpeg' => 'video/mpeg',
'mpg' => 'video/mpeg',
'mpga' => 'audio/mpeg',
'ms' => 'application/x-troff-ms',
'msh' => 'model/mesh',
'mxu' => 'video/vnd.mpegurl',
'nc' => 'application/x-netcdf',
'oda' => 'application/oda',
'ogg' => 'application/ogg',
'pbm' => 'image/x-portable-bitmap',
'pdb' => 'chemical/x-pdb',
'pdf' => 'application/pdf',
'pgm' => 'image/x-portable-graymap',
'pgn' => 'application/x-chess-pgn',
'png' => 'image/png',
'pnm' => 'image/x-portable-anymap',
'ppm' => 'image/x-portable-pixmap',
'ppt' => 'application/vnd.ms-powerpoint',
'ps' => 'application/postscript',
'qt' => 'video/quicktime',
'ra' => 'audio/x-realaudio',
'ram' => 'audio/x-pn-realaudio',
'ras' => 'image/x-cmu-raster',
'rdf' => 'application/rdf+xml',
'rgb' => 'image/x-rgb',
'rm' => 'audio/x-pn-realaudio',
'roff' => 'application/x-troff',
'rpm' => 'audio/x-pn-realaudio-plugin',
'rtf' => 'text/rtf',
'rtx' => 'text/richtext',
'sgm' => 'text/sgml',
'sgml' => 'text/sgml',
'sh' => 'application/x-sh',
'shar' => 'application/x-shar',
'silo' => 'model/mesh',
'sit' => 'application/x-stuffit',
'skd' => 'application/x-koan',
'skm' => 'application/x-koan',
'skp' => 'application/x-koan',
'skt' => 'application/x-koan',
'smi' => 'application/smil',
'smil' => 'application/smil',
'snd' => 'audio/basic',
'so' => 'application/octet-stream',
'spl' => 'application/x-futuresplash',
'src' => 'application/x-wais-source',
'sv4cpio' => 'application/x-sv4cpio',
'sv4crc' => 'application/x-sv4crc',
'svg' => 'image/svg+xml',
'swf' => 'application/x-shockwave-flash',
't' => 'application/x-troff',
'tar' => 'application/x-tar',
'tcl' => 'application/x-tcl',
'tex' => 'application/x-tex',
'texi' => 'application/x-texinfo',
'texinfo' => 'application/x-texinfo',
'tif' => 'image/tiff',
'tiff' => 'image/tiff',
'tr' => 'application/x-troff',
'tsv' => 'text/tab-separated-values',
'txt' => 'text/plain',
'ustar' => 'application/x-ustar',
'vcd' => 'application/x-cdlink',
'vrml' => 'model/vrml',
'vxml' => 'application/voicexml+xml',
'wav' => 'audio/x-wav',
'wbmp' => 'image/vnd.wap.wbmp',
'wbxml' => 'application/vnd.wap.wbxml',
'wml' => 'text/vnd.wap.wml',
'wmlc' => 'application/vnd.wap.wmlc',
'wmls' => 'text/vnd.wap.wmlscript',
'wmlsc' => 'application/vnd.wap.wmlscriptc',
'wrl' => 'model/vrml',
'xbm' => 'image/x-xbitmap',
'xht' => 'application/xhtml+xml',
'xhtml' => 'application/xhtml+xml',
'xls' => 'application/vnd.ms-excel',
'xml' => 'application/xml',
'xpm' => 'image/x-xpixmap',
'xsl' => 'application/xml',
'xslt' => 'application/xslt+xml',
'xwd' => 'image/x-xwindowdump',
'xyz' => 'chemical/x-xyz',
'zip' => 'application/zip');

//If you want to make default value TO DO here
//make default header
$this->AddHeader('MIME-Version', '1.0');
}

function SetFrom($str_Email, $str_ScreenName='')
{
if($str_ScreenName)
$this->sFrom = "$str_ScreenName <$str_Email>";
else
$this->sFrom = "$str_Email";
}

function AddTo($str_Email, $str_ScreenName='')
{
if($str_ScreenName)
$this->aTo[] = "$str_ScreenName <$str_Email>";
else
$this->aTo[] = "$str_Email";
}

function AddCc($str_Email, $str_ScreenName='')
{
if($str_ScreenName)
$this->aCc[] = "$str_ScreenName <$str_Email>";
else
$this->aCc[] = "$str_Email";
}
function AddCci($str_Email, $str_ScreenName='')
{
if($str_ScreenName)
$this->aCci[] = "$str_ScreenName <$str_Email>";
else
$this->aCci[] = "$str_Email";
}
function AddBcc($str_Email, $str_ScreenName='')
{
if($str_ScreenName)
$this->aBcc[] = "$str_ScreenName <$str_Email>";
else
$this->aBcc[] = "$str_Email";
}

function AddHeader($str_Header, $str_Value='')
{
$this->aHeader[] = $str_Header . ': ' . $str_Value;
}

function SetSubject($str_Subject)
{
$this->sSubject = $str_Subject;
}

function SetBodyText($str_Text)
{
$this->sBodyText = $str_Text;
}

function SetBodyHTML($str_HTML)
{
$this->sBodyHTML = $str_HTML;
}

function AddAttachPOSTFile($array_POSTFile)
{
$this->aPOSTFileAttach[] = $array_POSTFile;
}

function AddAttachLocalFile($str_LocalFile, $str_MimeType='')
{
if(!$str_MimeType)
{
//Auto detect mime type from file extention
preg_match("/\.[^.]+$/", $str_LocalFile, $aExt);
$sExt = strtolower(str_replace('.', '', $aExt[0]));
if($sExt)
{
if(isset($this->aMimeType[$sExt]))
$str_MimeType = $this->aMimeType[$sExt];
else
$str_MimeType = $this->sDefaultMimeType;
}
else
$str_MimeType = $this->sDefaultMimeType;
}

$aLocalFile = array();
$aLocalFile['tmp_name'] = $str_LocalFile;
$aLocalFile['name'] = preg_replace("/[^\/]*\//", '', $str_LocalFile);
$aLocalFile['type'] = $str_MimeType;
$aLocalFile['size'] = filesize($str_LocalFile);
$this->aLocalFileAttach[] = $aLocalFile;
//print_r($this->aLocalFileAttach);
}

function SetCharset($str_Charset)
{
$this->sCharset = $str_Charset;
}

function SetEncodingBit($int_Encoding)
{
$this->nEncoding = $int_Encoding;
}

//Generate Header for EML format
function ExportEML()
{
$aHeaderTemp = $this->aHeader;
$this->AddHeader('To', implode(', ', $this->aTo));
$this->AddHeader('Subject', $this->sSubject);
$this->AddHeader('Date', date('r'));
$sEmailHeader = $this->_MakeHeader();
$sEmailBody = $this->_MakeMessage();
$sEMail = $sEmailHeader . "\r\n\r\n" . $sEmailBody;
$this->aHeader = $aHeaderTemp;
return $sEMail;
}

//Send E-mail
function Send()
{
$sTo = implode(', ', $this->aTo);
$bResponse = mail($sTo, $this->sSubject, $this->_MakeMessage(), $this->_MakeHeader());
$sResponse = "mail($sTo,\" $this->sSubject\",\" ".$this->_MakeMessage()."\",\"".$this->_MakeHeader()."\");";

return $bResponse;
}

function _MakeHeader()
{
$aHeader = $this->aHeader;
$aHeader[] = "X-Mailer: cPHPezMail,1.0";
$aHeader[] = 'From: ' . $this->sFrom;
if($this->aCc)
$aHeader[] = 'Cc: ' . implode(', ', $this->aCc);
if($this->aCci)
$aHeader[] = 'Cci: ' . implode(', ', $this->aCci);
if($this->aBcc)
$aHeader[] = 'Bcc: ' . implode(', ', $this->aBcc);

if($this->sBodyHTML || $this->aFileAttach) //Check for multipart format
$aHeader[] = "Content-Type: multipart/mixed;\r\n boundary=\"{$this->sMimeBoundary}\"";
else
$aHeader[] = "Content-Type: text/plain; charset={$this->sCharset}";

return implode("\r\n", $aHeader);
}


function _MakeMessage()
{
$sMessage = '';
if($this->sBodyHTML || $this->aFileAttach) //Check for multipart format
{
//Start Multipart Format
$sMessage .= "This is a multi-part message in MIME format.\r\n";

if($this->sBodyText || $this->sBodyHTML)
{
//Open Alternative Part
$sMessage .= "--{$this->sMimeBoundary}\r\n";
$sMessage .= "Content-Type: multipart/alternative;\r\n boundary=\"{$this->sAltBoundary}\"\r\n\r\n";
}

if($this->sBodyText)
{
//Plain Text Message
$sMessage .= "--{$this->sAltBoundary}\r\n";
$sMessage .= "Content-Type: text/plain; charset={$this->sCharset}\r\nContent-Transfer-Encoding: {$this->nEncoding}bit\r\n\r\n";
$sMessage .= rtrim($this->sBodyText);
$sMessage .= "\r\n";
}

if($this->sBodyHTML)
{
//HTML Message
$sMessage .= "--{$this->sAltBoundary}\r\n";
$sMessage .= "Content-Type: text/html; charset={$this->sCharset}\r\nContent-Transfer-Encoding: {$this->nEncoding}bit\r\n\r\n";
$sMessage .= rtrim($this->sBodyHTML);
$sMessage .= "\r\n";
}

if($this->sBodyText || $this->sBodyHTML)
//Close Alternative Part
$sMessage .= "--{$this->sAltBoundary}--\r\n\r\n";

if($this->aPOSTFileAttach)
{
//Attach POST Files
foreach($this->aPOSTFileAttach as $aPOSTFile)
{
if(!$aPOSTFile['size'])
continue;

if(!is_uploaded_file($aPOSTFile['tmp_name']))
continue;

if(copy($aPOSTFile['tmp_name'], $this->sTempFileName))
{
$fpAttachFile = fopen($this->sTempFileName, 'rb');
if(!$fpAttachFile)
continue;

$sFileData = fread($fpAttachFile, $aPOSTFile['size']);
fclose($fpAttachFile);
@unlink($this->sTempFileName);

$sFileData = chunk_split(base64_encode($sFileData));
$sMessage .= "--{$this->sMimeBoundary}\r\n";
$sMessage .= "Content-Type: {$aPOSTFile['type']};\r\n name=\"{$aPOSTFile['name']}\"\r\n";
$sMessage .= "Content-Transfer-Encoding: base64\r\n";
$sMessage .= "Content-Disposition: attachment;\r\n filename=\"{$aPOSTFile['name']}\"\r\n\r\n";

$sMessage .= $sFileData;
}
}
}

if($this->aLocalFileAttach)
{
//Attach Local Files
foreach($this->aLocalFileAttach as $aLocalFile)
{
if(!$aLocalFile['size'])
continue;

$fpAttachFile = fopen($aLocalFile['tmp_name'], 'rb');
if(!$fpAttachFile)
continue;

$sFileData = fread($fpAttachFile, $aLocalFile['size']);
fclose($fpAttachFile);

$sFileData = chunk_split(base64_encode($sFileData));
$sMessage .= "--{$this->sMimeBoundary}\r\n";
$sMessage .= "Content-Type: {$aLocalFile['type']};\r\n name=\"{$aLocalFile['name']}\"\r\n";
$sMessage .= "Content-Transfer-Encoding: base64\r\n";
$sMessage .= "Content-Disposition: attachment;\r\n filename=\"{$aLocalFile['name']}\"\r\n\r\n";

$sMessage .= $sFileData;
}
}

//Close Message
$sMessage .= "--{$this->sMimeBoundary}--\r\n";
}
else
{
//Start Plain Text Format
$sMessage .= $this->sBodyText;
}
return $sMessage;
}
}
?>
Viejo 24.10.09, 19:24
esa clase termina usando la función mail Solo los usuarios registrados pueden ver los links. ¡Registrate ahora, es gratis! para enviarlo (mira el método Send). Esta función no permite especificar el servidor smtp.
Ahora, esixten estas variables de configuración que afectan en la que se pueden especificar el server smtp; pero esto solo se aplica si estas Windows (Solo los usuarios registrados pueden ver los links. ¡Registrate ahora, es gratis! la variable SMTP y la relacionada al port del servidor (esta variable la podes setear en php.ini o usando ini_set("SMTP", ip o nombre de dominio del server). Igual, esta forma de enviar email parece que tiene muchos problemas.
Bajo Linux, lo que se usa es una aplicación externa (sendmail en general) para que esta trasmita el email; esta es la aplicación que deberías configurar para que trabaje como vos quieras (aunque creo que sendmail puede enviar directamente los emails a los server smtp "destino" sin necesita de un usar un server intermedio; en este sentido no requiere que le especifiques que server smtp usar).
"It is better to be beatiful than to be good. But... it is better to be good than to be ugly." (Oscar Wilde) Era jodido Oscarcito...
"Why do programmers get Halloween and Christmas mixed up? Because OCT(31) = DEC(25)"
"De vez en cuando la vida toma conmigo ferne' ...." (el_bot)
AntiMW VBS Tools (saca los virus con notepad!!!)

Última edición por el_bot: 16 de agosto de 1981 a la tardecita. Razón: nací.
Viejo 26.10.09, 20:41
Hola bot, entiendo que el php.ini no lo puedo modificar por que esta en el servidor, ahora la pregunta es, debro crear el archivo ini_set y subirlo para que todos los archivos que hacen referencia al evio de mail del script se lean a este?
Viejo 27.10.09, 00:34
se me borro el mensaje anterior....
Ok, lo repito mas o menos:
No, ini_set es una función php predefinida y la llamas como a cualquier otra función. El tema es que la tenes que llamar para setear el valor de la variable de configuración SMTP antes de enviar el email (setear una variable usando ini_set, cuando esta permitido, es lo mismo que modificarla en php.ini).
Por ej
Código:
//una de las priemra cosas que debe hacer tu script
//setear el nombre o ip del servidor smtp
ini_set("SMTP","smtp.example.com" ); 

.... todo lo demas ocmo antes

... y por ulitmo

//o es un objeto de la clase cPHPezMail inicializada 
o.Send(); //send va a usar internamente la función mail()
//la cual, SI EL SERVIDOR ESTA CORRIENDO BAJO WINDOWS,
//va a enviar el email al server smtp especificado en la variable SMTP
(también existe otra forma de setear la variable SMTP usando un arhcivo .htaccess; esto te evita tenes que llamar a explictamente a ini_set)

Te repito; esto solo sirve si el servidor web que estas usando corre bajo Windows (lo cual es muyyyyyyyyyyyy poco probable); y aun en ese caso puede que no sirva (la variable de configuración STMP solo tiene uso bajo Windows Y CUANDO la variable sendmail_path NO esta seteada). De todas maneras; aun cuando puedas hacer andar la variable SMTP, el envió de email bajo Windwos es bastante malo (hay cosas que no funcionan como deberian ) y tiene sus limitaciones; por ej, no podes autentificarse en el server stmp.
"It is better to be beatiful than to be good. But... it is better to be good than to be ugly." (Oscar Wilde) Era jodido Oscarcito...
"Why do programmers get Halloween and Christmas mixed up? Because OCT(31) = DEC(25)"
"De vez en cuando la vida toma conmigo ferne' ...." (el_bot)
AntiMW VBS Tools (saca los virus con notepad!!!)

Última edición por el_bot: 16 de agosto de 1981 a la tardecita. Razón: nací.
Viejo 31.10.09, 15:06
Bajate el libmail, te soluciona la vida para todo tipo de envíos...
The stars are blazing like rebel diamonds cut out of the sun...
Viejo 01.11.09, 11:12
Como configuro sendmail, por que el servidor esta esta bajo linux
Viejo 01.11.09, 19:14
El libmail es un documento PHP que te incluye la función mail() cuando no la tenés habilitada en el servidor (generalmente suele ser porque no es dedicado), así que no vas a tener dramas para usarlo con linux, y no tenés que configurar nada (bah, podes configurarlo a tu antojo si tenes un mínimo de conocimientos de programación, pero no es requisito indispensable...)
The stars are blazing like rebel diamonds cut out of the sun...
Viejo 02.11.09, 09:40
Originalmente publicado por gabriela.rgb Ver mensaje
El libmail es un documento PHP que te incluye la función mail() cuando no la tenés habilitada en el servidor (generalmente suele ser porque no es dedicado), así que no vas a tener dramas para usarlo con linux, y no tenés que configurar nada (bah, podes configurarlo a tu antojo si tenes un mínimo de conocimientos de programación, pero no es requisito indispensable...)
Nop... estas en la misma; libmail es una encapsulación de la función mail() de php.

"this class encapsulates the PHP mail() function.
implements CC, Bcc, Priority headers"

Este es el codigo del metodo Send()
Código:
function Send()
{
    $this->BuildMail();
    
    $this->strTo = implode( ", ", $this->sendto );
    
    // envoie du mail
    $res = @mail( $this->strTo, $this->xheaders['Subject'], $this->fullBody, $this->headers );

}
En cuanto al tema de como se configura sendmail, no se, pero no creo que lo puedas hacer (para configurar sendmail tenes que administrar el servidor; y vos dijiste que no tenias acceso al php.ini así que tampoco vas a poder configurar sendmail). Sendmail no se configura desde php; se configura como cualquier otro programa.
"It is better to be beatiful than to be good. But... it is better to be good than to be ugly." (Oscar Wilde) Era jodido Oscarcito...
"Why do programmers get Halloween and Christmas mixed up? Because OCT(31) = DEC(25)"
"De vez en cuando la vida toma conmigo ferne' ...." (el_bot)
AntiMW VBS Tools (saca los virus con notepad!!!)

Última edición por el_bot: 16 de agosto de 1981 a la tardecita. Razón: nací.

Herramientas Buscar en este tema
Buscar en este tema:

Búsqueda avanzada
Este tema está relacionado con otros ya publicados en el sitio. Podés visitarlos ahora!
Tema Foro Último mensaje
Envío de Currículum Empleos 28.04.09 14:11
Alli Les Envio Otras Fotitos De Mi Cola Tu Material 21.02.09 16:28
Envio falso de email Chat, E-Mail y Mensajeros 16.07.08 16:02
envio de juegos Abandonware y Emuladores 03.06.08 13:06
como envio msj manuscritos con msn?? help!! Chat, E-Mail y Mensajeros 18.12.06 11:40

Iniciar Sesion

Recordarme
ElServer