In my index view file I have an enquiry form from which the user can receive eamil on form submission
In the form tag I have set the action as: <form method="post" action="site/thanks"
In controller I have created a function:
public function actionThanks()
{
$headers="From: promo@elysianrealestate.com\r\nContent-type: text/html\r\nReply-To: promo@elysianrealestate.com";
mail($_POST['txtEmail'],"Home Page Enquiry",$body,$headers);
$this->render('error', $error);
$this->render('thanks');
}
I want to send an html email. The html message is an html file emailcontent.html. Do I need to make it a php file or keep it as html. Also, how do I pass it $_POST data coming from index view ? And use the html file content as $body in the mail() function. Do I need to create another function in the controller ? thanks.php is the view file to be shown when the email is sent.
but I’m getting this error: Undefined index: txtYourName
In index.php I have <form method="post" action="site/thanks" onsubmit="return validate();"> and <input type="text" value="Name: *" size="35" name="txtYourName" id="txtYourName" …, then why am I getting this error ?
This was because I was directly accessing that page by changing my url because the action="site/thanks" was taking me to localhost/mysite/site/thanks Not found page instead of mysite/index.php/site/thanks
Now that I’m using action=“index.php/site/thanks”, I get this error
mail() [<a href=‘function.mail’>function.mail</a>]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set()
Maybe it will work after I upload the files and test on server