Hello guys,
I need some help here... I making a contact form using Cakephp 1.2.
The problem upon sending email..The notification was successful but I
couldn't receive the email....Is there something wrong with my code?
Can anyone help me here?
Form view:
<?php echo $form->create("Guest" array("url"=>"controller/contact")); ?
>
<?php echo $form->input("Guest.name"); ?>
<?php echo $form->input("Guest.phone"); ?>
<?php echo $form->input("Guest.email"); ?>
<?php echo $form->input("Guest.message"); ?>// automagic lay-out.
///captcha...
<?php echo $form->input("Guest.code"); ?>//
<?php echo $form->submit("Send"); ?>
<?php echo $form->end(); ?>
//controller function
function contact(){
// Using built in validation
if(!empty($this->data['Guest'])){
$validation = new Validation();
if($validation->blank($this->data["Guest"]["name"])) {
$this->Session->setFlash("Name cannot be
blank.");
$this->data["Guest"]["code"] = "";
//redirect somewhre...
return;
}
if($validation->blank($this->data["Guest"]["email"])) {
$this->Session->setFlash("Email cannot be
blank.");
$this->data["Guest"]["code"] = "";
//redirect somewhre...
return;
}
if(!$validation->email($this->data["Guest"]["email"])) {
$this->Session->setFlash("Invalid email.");
$this->data["Guest"]["code"] = "";
//redirect somewhre...
return;
}
if($validation->blank($this->data["Guest"]["message"]))
{
$this->Session->setFlash("Message cannot be
blank.");
$this->data["Guest"]["code"] = "";
//redirect somewhre...
return;
}
$caseInsensitive = true;
$val = $this->data['Guest']['code'];
if ($caseInsensitive) {
$val = strtoupper($val);
}
if(!defined('CAPTCHA_SESSION_ID'))
define('CAPTCHA_SESSION_ID', 'php_captcha');
if (!empty($_SESSION[CAPTCHA_SESSION_ID]) && $val ==
$_SESSION[CAPTCHA_SESSION_ID]) {
// clear to prevent re-use
unset($_SESSION[CAPTCHA_SESSION_ID]);
} else {
$this->Session->setFlash("Invalid code.");
$this->data["Guest"]["code"] = "";
//redirect somewhre...
return;
}
App::import('Sanitize');
$mrClean = new Sanitize();
$mrClean->clean($this->data['Guest']);
$data = $this->data['Guest'];
$this->set ( "data", $data );
$this->Email->template = 'my_email_template';
$settings = $this->requestAction("my own
server settings");
$this->set('settings', $settings);
// You can use customised thmls or the default ones you
setup at
the start
//$this->set('data', $data);
$this->Email->to = 'email where im goin send';
$this->Email->subject = 'subject';
$this->Email->bcc = array('email where im goin send');
$this->Email->from = $this->data["Guest"]["name"] . "
<" . $this-
>data["Guest"]["email"] . ">";
if($settings["AppModel"] == "use_smtp") {/// database
config
settings
/* SMTP Options */
$this->Email->smtpOptions = array(
'port'=> '25',
'timeout'=> '30',
'auth'=> true,
'host' => 'mail.xxxxxxxxxx.com',
'username'=> '[email protected]',
'password'=> 'xxxxxxxxxx'
);
$this->Email->delivery = 'smtp';
}
$this->Email->sendAs = 'html';
$result = $this->Email->send ();
if($result){
$flash = "Your inquiry has been sent.
Thank you for contacting
us.";
$this->Session->setFlash($flash);
//redirect somewhere
return;
}
else
{
$flash = "Unable to sent your inquiry.
Please try again in a few
minutes.". $this->Email->smtpError;
$this->Session->setFlash($flash);
//redirect somewhere
return;
}
}
//redirect somewhere
}
Thanks,
randalle2
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---