사용자가보고있는 기사를 전자 메일로 보낼 수있는 곳을 개발 중입니다. 나는 이것을 처리하기 위해 Ajax를 사용하고있다. 기본적으로 사용자는 자신의 이메일/이름과 메시지가 전송 될 사람의 이메일을 추가합니다. 내 cakephp 함수에 데이터 배열을 전달하는 데 문제가있다. 데이터가 배열에 정확하게 배치되지만 CakePHP 함수에서 전송되는 이메일을 볼 수 없습니다.CakePHP 1.3 : Ajax를 사용하여 전자 메일 양식 처리
내 자바 스크립트 코드
var dataString = new Array();
dataString[0] = name;
dataString[1] = email;
// This will display Joe Schmoe, [email protected]
alert(dataString); return false;
$('#contact-area').html("<div id='Sending' style='margin-left:410px;color:red;border:1px solid red'>Enviando...Por favor, aguarde um momento!</div>");
$.ajax({
type: "POST",
url: "/articles/enviar",
data: dataString,
success: function() {
$('#Sending').hide();
$('#contact-area').html("<div id='message' style='margin-left:410px;color:red;border:1px solid red'></div>");
$('#message').html("<h3>A Sua Mensagem Ja Foi Enviada!</h3>")
.append("<p>Obrigado.</p>")
.hide()
내 컨트롤러 조치
function enviar(){
//debug($emailInfo);
// Send email with new password
$this->Email->to = '[email protected]';//testing without array
$this->Email->subject = 'Hello';//$emailInfo['name'].' - Noticia Na Bravanews';
$this->Email->from = '[email protected]';//testing without array
$this->Email->sendAs = 'html';
$this->Email->template = 'enviar_email';
$this->Email->smtpOptions = array(
'port'=>'465',
'timeout'=>'30',
'host' => 'ssl://smtp.gmail.com',
'username'=>'[email protected]',
'password'=>'xxxxxxxx'
);
$this->Email->delivery = 'smtp';
// this displays as nothing
$this->set('emailInfo', $this->data);
if($this->Email->send()){
return true;
}else{
return false;
}
}
그리고 내 이메일 템플릿
Hello,<br />
<?php e($emailInfo[0]); ?> sugeriu que leias a seguinte notícia na Bravanews.<br>
<?php e($emailInfo[1]); ?><br>
Por favor clique no link abaixo:<br /><br>
<?php debug($emailInfo); ?>
어떻게이 문제를 해결 가야합니까. 나는 인쇄물이나 이메일을 보낼 수 있도록 이메일 템플릿에 아무 것도 바꿀 수 없습니다 ...
고마워요. 이것은 내가 잘못하고있는 것입니다. 모든 것이 훌륭하게 작동하며 내 이메일 템플릿에서 양식 데이터를 읽고 표시 할 수 있습니다. 큰! 나는 모델을 사용하지 않아도되지만, 똑같은 일은 거의 없다. data : {data [email] : email, data [name] –