Ver Mensaje Individual
  #1 (permalink)  
Antiguo 24/09/2008, 20:37
Avatar de zeroblend
zeroblend
 
Fecha de Ingreso: abril-2008
Ubicación: La Ceja
Mensajes: 5
Antigüedad: 16 años
Puntos: 0
Pregunta Problema con envio masivo

Hola a todos.
Acabo de diseñar una aplicación para email marketing usando cakephp. He estado haciendo pruebas y no logro que el sistema haga el envío de todos los mensajes. En un servidor manda solo 100 y en otro solo 800. He contratado un servicio aparte de smtp el cual posee un límite de 5000 email por mes. En una lista de 1000 sólo manda los ya nombrados.
Alguien sabe a qué se puede deber?
El servicio smtp es authsmtp.com.
Aquel me me pueda colaborar se lo agradeceré.
El script se comunica sin problemas con authsmtp, pero no lo entiendo que detiene el envío, o que detiene el script.
Saludos!!

Código:
function send()
	{
		set_time_limit(0);
		ignore_user_abort(true);
		$date = date('d-m-Y-G-i');
		list($day, $month, $year,$hour,$min) = split("-",$date, 6);
		$criteria = "fecha_day = $day AND fecha_month = $month AND fecha_year = $year AND fecha_hour = $hour AND fecha_min = $min" ; 
		$camps = $this->Client->findAll($criteria);
		$this->Email->smtpHostNames = 'mail.authsmtp.com';
     	$this->Email->smtpAuth = true;
     	$this->Email->smtpUserName = 'myusername';
     	$this->Email->smtpPassword = 'mypassword';
        $this->Email->from = '[email protected]';
        $this->Email->port = '2525';
		foreach ($camps as $c):
			$envios = 0;
			$rebotes = 0;
			$i = 0;
				
			$t = $this->Client->Template->find('Template.id = \''.$c['Client']['template_id'].'\'');
			$l = $this->Client->Lista->find('Lista.id = \''.$c['Client']['list_id'].'\'');
			$user = $this->Client->User->find('User.id = \''.$c['Client']['user_id'].'\'');
			$list = $l['Lista']['correos'];
			$strToken=strtok($list,"\r\n");
			$data = $t['Template']['template';
			$this->Email->html_body = $data;
			$this->set('content_for_layout', $data);
      	$this->Email->subject = $t['Template']['asunto'];
      	$this->Email->fromName = $t['Template']['remitente'];
      	$this->Email->replyTo = $t['Template']['responder'];
      	$credit = $user['Profile']['creditos'];
      	while($strToken){
      		list($userName, $mailDomain) = split("@", $strToken);
      		if (checkdnsrr($mailDomain, "MX")) {
 				// this is a valid email domain!
 				$this->Email->to = $strToken;
				if($credit > 0)
				{	
					if(!empty($strToken))
 					{
						$result = $this->Email->send();
					}
      			if($result == true)
      			{
      				$credit = $credit - 1;
      				$this->data['Profile']['id'] = $user['User']['id'];
						$this->data['Profile']['creditos'] = $credit;
      				$this->Client->User->Profile->save($this->data);
	      			$envios = $envios + 1;
      			}else{
	      			$rebotes = $rebote + 1;
      			}
      
      			$this->data['Client']['id'] = $c['Client']['id'];
      			$this->data['Client']['enviado'] = $envios;
      			$this->data['Client']['rebote'] = $rebotes;
      			$this->Client->save($this->data);

					
				}else{
					$rebotes = $rebotes +1;
					$this->Client->id = $c['Client']['id'];
					$this->Client->saveField('rebote',$rebotes);
				}
				if($i == 50)
				{
					sleep(30);
					$this->Email->from = '[email protected]';					
				}
				if($i == 100)
				{
					sleep(30);
					$this->Email->from = '[email protected]';
				}
				if($i == 150)
				{
					sleep(30);
					$this->Email->from = '[email protected]';
				}				
				$strToken=strtok("\r\n");
				}
				else {
 				// this email domain doesn't exist! bad dog! no biscuit!
 				$rebotes = $rebote + 1;
 				$this->log($strToken, LOG_ERR);
 				$strToken=strtok("\r\n");
			}
			$i = $i + 1;
		}	
		endforeach;
		exit();
	}