Encontre una funcion para enviarlo por SMTP pero no eh podido configurar la parte del Servidor de Email, la cual es esta:
Código PHP:
$smtpServer = ‘www.tuservidordemail.com’;
$port = ‘25′;
$timeout = ‘60′;
$username = ‘tunombreusuario’;
$password = ‘tupassword’;
$localhost = ‘www.tudominio.com’;
$newLine = “rn”;
Código PHP:
$smtpServer = 'ssl://smtp.googlemail.com';
$port = '465';
$timeout = '60';
$username = '[email protected]';
$password = 'contrasena123456';
$localhost = 'sql201.byethost52.com';
$newLine = "\r\n";
Dejo la funcion completa como la encontre en la red por si no me di a entender bien XD
Código PHP:
/**
* Esta funcion permite enviar un email en formato:
* texto o html por protocolo SMTP.
*
* Auto: Edwin Sandoval < contacto [at] perfilgeek.com >
*
* @param String $format
* @return boolean
*/
function mailporsmtp( $mail_from = '',
$mail_to = '',
$mail_cc = '',
$mail_bcc = '',
$mail_subject = '',
$mail_data = '',
$mail_format = 'text' ){
$smtpServer = 'www.tuservidordemail.com';
$port = '25';
$timeout = '60';
$username = 'tunombreusuario';
$password = 'tupassword';
$localhost = 'www.tudominio.com';
$newLine = "\r\n";
$conexionsmtp = fsockopen( $smtpServer, $port, $errno, $errstr, $timeout );
fputs( $conexionsmtp,' AUTH LOGIN'.$newLine );
fputs( $conexionsmtp, base64_encode( $username ) . $newLine );
fputs( $conexionsmtp, base64_encode( $password ) . $newLine );
fputs( $conexionsmtp, 'HELO ' . $localhost . $newLine );
fputs( $conexionsmtp, 'MAIL FROM: ' . $mail_from . $newLine );
fputs( $conexionsmtp, 'RCPT TO: ' . $mail_to . $newLine );
if( !empty( $mail_cc ) ){
fputs( $conexionsmtp, 'RCPT TO: ' . $mail_cc . $newLine );
}
if( !empty( $mail_bcc ) ){
fputs( $conexionsmtp, 'RCPT TO: ' . $mail_bcc . $newLine );
}
fputs( $conexionsmtp, 'DATA' . $newLine );
fflush( $conexionsmtp );
$raw = "";
$raw = @fread( $conexionsmtp, 255 );
$raw .= @fread( $conexionsmtp, 255 );
fputs( $conexionsmtp, 'To: ' . $mail_to . $newLine );
fputs( $conexionsmtp, 'From: <' . $mail_from .'>' . $newLine );
fputs( $conexionsmtp, 'Subject:' . $mail_subject . $newLine );
if( $mail_format == 'text' ){
$headers = "Content-Type: text/plain; charset=\"iso-8859-1\"" . "\r\n";
$headers .= "Content-Transfer-Encoding: 7bit" . "\r\n";
$message = $mail_data;
fputs( $conexionsmtp, $headers . $newLine . $newLine );
fputs( $conexionsmtp, $message . $newLine . '.' . $newLine );
}else{
$random_hash = md5(date('r', time()));
$headers = "Content-Type: multipart/alternative; boundary=\"PHP-alt-".$random_hash."\"\r\n";
$headers .= "--PHP-alt-" . $random_hash . "\r\n";
$headers .= "Content-Type: text/plain; charset=\"iso-8859-1\"" . "\r\n";
$headers .= "Content-Transfer-Encoding: 7bit" . "\r\n";
$message = $mail_data[0];
fputs( $conexionsmtp, $headers . $newLine );
fputs( $conexionsmtp, $message . $newLine );
$headers = "--PHP-alt-" . $random_hash . "\r\n";
$headers .= "Content-Type: text/html; charset=\"iso-8859-1\"" . "\r\n";
$headers .= "Content-Transfer-Encoding: 7bit" . "\r\n";
$message = $mail_data[1];
fputs( $conexionsmtp, $headers . $newLine );
fputs( $conexionsmtp, $message . $newLine );
$headers = "--PHP-alt-" . $random_hash . "--\r\n";
fputs( $conexionsmtp, $headers . '.' . $newLine );
}
fputs( $conexionsmtp,'QUIT' . $newLine );
return true;
}
Código PHP:
$mail_from = '' // Dirección de Correo Remitente
$mail_to = '' // Dirección de Correo Destinatario
$mail_cc = '' // Dirección de Correo Destinatario
$mail_bcc = '' // Dirección de Correo Destinatario
$mail_subject = '' // Asunto del Mensaje
$mail_data = '' // Texto Plano o un Array ( $mail_data[0] = 'texto plano'; $mail_data[1] = '<p>html mail</p>'; )
$mail_format = 'text' // Formato del Email ( text o html )