Hi guys below have a question I want to add more input mail variables is there any one can assist me better way please
PHP Code:
<?php
namespace App\Controllers;
use App\Models\FormModel;
use CodeIgniter\Controller;
class SendMailController extends Controller
{
public function index()
{
return view('form_view');
}
function sendMail() {
$to='[email protected]';
$from = $this->request->getVar('mailTo');
$subject = $this->request->getVar('subject');
$message = $this->request->getVar('message');
/*$solo = $this->request->getVar('solo'); here I want to add more input*/
/*$solo = $this->request->getVar('solo2') ; here I want to add more input*/
$email = \Config\Services::email();
$email->setTo($to);
$email->setFrom($from, 'Thank you');
$email->setSubject($subject);
$email->setMessage($message);/*i want to chunk message here*/
//This is wrong
//$email->setBody($solo);
//$email->setBody($solo2);
if ($email->send())
{
//echo 'Email successfully sent';
return redirect()->back()->with('message', 'Email successfully sent');
}
else
{
$data = $email->printDebugger(['headers']);
print_r($data);
}
}
}
and here is a form
Code:
<form>
<input name="mailTo"/>
<input name="subject"/>
<input name="message"/>
<input name="solo"/>
<input name="solo2"/>
</form>
Codeigniter First, Codeigniter Then You!!
yekrinaDigitals