Sending email problem


#1

When i execute my code i get [message Could not instantiate mail function.]

use \OxidEsales\Eshop\Core\Email;

class AskForPrice extends oxUBase{

public function sendEmail(){
	$oEmail = oxNew(\OxidEsales\Eshop\Core\Email::class);
	$aParams = oxConfig::getRequestParameter('editval');
  		$myConfig = oxRegistry::getConfig();
            $emailTo = oxConfig::getRequestParameter('adminemailto');
            $sName = $aParams['name'];
            $sEmail = $aParams['email'];
            $sSubject = $aParams['subject'];
            $sMessage = $aParams['message'];			
            $oEmail->sendContactMail($sEmail,$sSubject,$sMessage);      
}

}

Does anyone know whats the problem or can give me any hint?


#2

Short question: The other OXID original mails can send? So the Question is if you have a global mail problem.


#3

Yes i can send an email from the original contact form from oxid.


#4

Hm with small modifications it works for me.
try this one:
use OxidEsales\Eshop\Core\Registry;
use OxidEsales\Eshop\Core\Request;

class AskForPrice extends OxidEsales\Eshop\Application\Controller\FrontendController {
publicfunctionsendEmail(){
$oEmail=oxNew(\OxidEsales\Eshop\Core\Email::class);
$aParams=Registry::get(Request::class)->getRequestEscapedParameter(‘editval’);
$sEmail=$aParams[‘email’];
$sSubject=$aParams[‘subject’];
$sMessage=$aParams[‘message’];
$oEmail->sendContactMail($sEmail,$sSubject,$sMessage);
}
}

If this wont work you can upload your Modul to github or somewhere we can see the code completly :wink: