Foros del Web » Programando para Internet » Javascript »

Newsletter en ajax y WYSIWYG

Estas en el tema de Newsletter en ajax y WYSIWYG en el foro de Javascript en Foros del Web. Hola!, esta es mi primer consulta. Estoy intentando comprender un poco mas el javascript y ahora se me presenta este problema. Como es combinado quizas ...
  #1 (permalink)  
Antiguo 18/09/2009, 13:52
 
Fecha de Ingreso: septiembre-2009
Mensajes: 1
Antigüedad: 14 años, 8 meses
Puntos: 0
Newsletter en ajax y WYSIWYG

Hola!, esta es mi primer consulta.
Estoy intentando comprender un poco mas el javascript y ahora se me presenta este problema.

Como es combinado quizas deba ir en el foro de Ajax, pero bueno

Estoy usando un módulo de newsletter en ajax, que todos deben conocer, muy interesante virae.org/newsletter_module

El tema es que quiero instalarle un editor WYSIWYG en la parte de escribir el cuerpo de mail. He probado con mucho, sino todos los editores y los puedo instalar bien, pero cuando se envía el newsletter, el contenido del mail llega "Undefined".

El problema que yo veo es que el iframe que se despliega arriba del textarea no le pasa el contenido del mail a la función de envío de mail....
Alguien me puede tirar una lína de como hacer esto?

Ah, estoy usando el CKEditor

Este es el código del textarea
Código:
						<input type="text" id="subject" style="width:400px;" /><br />
						<br />
						<h3>
							Mensaje
						</h3><br />						
                        <br /><textarea id="emailbody" class="ckeditor" cols="40" rows="8" >Escribí tu mensaje aquí...</textarea>
		        <br /><br /><br />
						<br />
					</div>
					<div style="float:right;width:500px;text-align:center;padding-top:120px;"></div>
						<a class="backlink"><img onClick="sendmail();" src="images/go.png" alt="send!" />
Código:
function sendmail() {
	  $('#processing').fadeIn(500);
	  $.post("index.php", {
			  action: 'sendmail', sendto: sendto, attachment: $('#filename').val(), subject: $('#subject').val(), ebody: $('#emailbody').val(), adresses: adresses }, function(response){

				var response = eval('(' + response + ')');
				if (response.error != '') {alert(response.error);}
				else {
				  var previoushtml = $('#processing').html();
				}
			  }
		);
	  setTimeout("$('#processing').fadeOut(1000)",2500);
	}   
	// ***
	
	// DOC READY
	$(document).ready(function() {
		// hide processing div
			$('#processing').hide();
		// hide all e-mail divs
			$('.mails').hide();
		// show the first div
			$('#category_<?php echo $categories[0]['id'];?>').show();
	});
Y de aquí sale el mail

Código:
if ($_POST['action']=='sendmail') {
		
		if ($use_template == false ) { $template_top = ''; $template_bottom = '';}
	
		  $emails = $_POST['adresses'];
		  $body = $_POST['ebody'];
		  $subject = $_POST['subject'];
		  $message = str_replace("\n","<br />",$body);
	
		/* ERRORS */
		if ($message == '') {$error = 'Please, fill the message field !';}
		if ($subject == '') {$error = 'Please, fill the subject field !';}
		if (empty($emails)) {$error = 'No recipient defined ! ';}
	
		if (!empty($emails) && empty($error)) {
	
			/* ZAPIS DO ODOSLANÝCH NEWSLETTROV */
	
				$q = "INSERT INTO $table_sent (time, subject, body, attachment) VALUES (
				".sql_quote(time()).",
				".sql_quote($subject).",
				".sql_quote($message).",
				".sql_quote($_POST["attachment"]).")";
				mysql_query($q);
	
			$from = "$your_name <$your_email>";
			
			if (!empty($_POST["attachment"])) {
	
				  $suffix  =strtolower(substr($dir.$_POST["attachment"], -3));
					  switch($suffix) {
						case 'gif': $typ = "image/gif"; break;
						case 'jpg': $typ = "image/jpg"; break;
						case 'peg': $typ = "image/jpeg";break;
						case 'png': $typ = "image/png"; break;
						case 'pdf': $typ = "application/pdf"; break;
						case 'zip': $typ = "application/zip"; break;
					  }
				  
				  $subject = $_POST['subject'];
	
				  $fileatt = $dir.$_POST["attachment"];
				  $fileatttype = $typ;
				  $fileattname = $_POST["attachment"];
	
				  $headers = "From: $from";
	
				  $file = fopen( $fileatt, 'rb' );
				  $data = fread( $file, filesize( $fileatt ) );
				  fclose( $file );
	
				  $semi_rand = md5( time() );
				  $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
	
				  $headers .= "\nMIME-Version: 1.0\n" .
							  "Content-Type: multipart/mixed;\n" .
							  " boundary=\"{$mime_boundary}\"";
	
				  $message = "This is a multi-part message in MIME format.\n\n" .
						  "--{$mime_boundary}\n" .
						  "Content-Type: text/html; charset=\"utf-8\"\n" .
						  "Content-Transfer-Encoding: 7bit\n\n" .
						  $template_top.$message.$template_bottom . "\n\n";
	
				  $data = chunk_split( base64_encode( $data ) );
	
				  $message .= "--{$mime_boundary}\n" .
						   "Content-Type: {$fileatttype};\n" .
						   " name=\"{$fileattname}\"\n" .
						   "Content-Disposition: attachment;\n" .
						   " filename=\"{$fileattname}\"\n" .
						   "Content-Transfer-Encoding: base64\n\n" .
						   $data . "\n\n" .
						   "--{$mime_boundary}--\n";
	
		  }
		  else
		  {
	
				  $subject = $subject." \n";
	
				  /* HEADERS */
	
					$headers = "MIME-Version: 1.0\n";
					$headers .= "Content-Type: text/html; charset=\"utf-8\"\n";
					$headers .= "Content-Transfer-Encoding: 7bit \n";
					$headers .= "From: ".$from." \n";
					$headers .= "Return-Path: ".$from." \n";
					$headers .= "X-Mailer: PHP/" . phpversion();
	
					$message = $template_top.$message.$template_bottom;
	
		  }
	
			if ($_POST['sendto']=='emails') {
		    	
				$email = explode(',',$emails);
				$email = array_unique($email);
	    	}
	    	else if ($_POST['sendto']=='categories') {
		
	    		$query = "SELECT * from $table_emails WHERE category IN (".$emails.")";
	    		$select = mysql_query($query);
	    		while ($mail_row = mysql_fetch_assoc($select)) {
	    			$email[] = $mail_row['id'];
	    		}
	    	}

			/* ADMIN CHECK */
			if ($mailcheck == true && !in_array($your_email,$email )) {
				$email[] = $your_email;
			}
			
			foreach ($email as $value) {
			  
				$emailaddress = sql_getfield($table_emails,'email','WHERE id = '.sql_quote($value));
				$unsubscribe_link = "<br /><br /><span style=\"font-size:10px;color:#555;\">If you prefer not to receive future promotional e-mails of this type, please click 
				<a href=\"".$script_url."?unsubscribe=".$emailaddress."\" style=\"color:#ED008C;\">here</a> to unsubscribe.";
				mail($emailaddress, "=?UTF-8?B?".base64_encode($subject)."?=", $message.$unsubscribe_link, $headers);
				$count+=1;
			
			}
	
		  }
	
			  echo "{";
			  echo "error: '" . $error . "',\n";
			  echo "count: '" . $count . "'\n";
			  echo "}";
	
		exit();
			  
	}
Si alguien puede ayudarme se lo agradezco.
Saludos!
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 02:40.