File: /var/www/vhosts/creativefellows.nl/jhtaxatie.creativefellows.nl/classes/TaxationEmail.php
<?php
class TaxationEmail
{
public function __construct()
{
$this->email = new PHPMailer(true);
$this->email->isSMTP(); //important
$this->email->isHTML(true);
$this->email->SMTPDebug = 0;
$this->email->CharSet = 'UTF-8';
$this->email->Host = 'server098.yourhosting.nl';
$this->email->Port = 587;
$this->email->SMTPSecure = 'tls';
$this->email->SMTPAuth = true;
$this->email->Username = 'no-reply@mijnjungheinrich.nl';
$this->email->Password = 'Gc80c7k~0';
$this->email->SMTPOptions = [
'ssl' => [
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true,
]
];
}
public function setSubject($email_subject)
{
$this->email->Subject = $email_subject;
}
public function setTemplate($type,$array_params)
{
$this->type = $type;
switch($this->type)
{
case "taxation":
$keys = array_keys($array_params);
$values = array_values($array_params);
$this->email->Body = preg_replace($keys,$values,"<p><strong>{advisor} </strong>heeft een nieuw taxatierapport voor <strong>{company}</strong> aangemaakt.</p><p>Ga naar <a href=\"{route}\">{route}</a> om dit rapport te bekijken en een waarde toe te kennen.</p>");
break;
case "complete":
$keys = array_keys($array_params);
$values = array_values($array_params);
$this->email->Body = preg_replace($keys,$values,"<p>Beste {advisor},</p><p>De waarde van het taxatierapport voor <strong>{company}</strong> is toegekend.</p><p>Ga naar <a href=\"{pdf_path}\">{pdf_path}</a> om dit rapport te bekijken.</p><p>Met vriendelijke groet,<br />{gg_user_name}</p>");
break;
case "enquiry":
$keys = array_keys($array_params);
$values = array_values($array_params);
$this->email->Body = preg_replace($keys,$values,"<p><strong>{advisor} </strong>heeft een aanvraag voor <strong>{company}</strong> ingestuurd.</p><p>Ga naar <a href=\"{route}\">{route}</a> om deze te bekijken en op te volgen.</p>");
break;
case "inspection":
$keys = array_keys($array_params);
$values = array_values($array_params);
$this->email->Body = preg_replace($keys,$values,"<p>Het keuringsformulier voor <strong>{company}</strong> te {city} kun je hier downloaden op de volgende link <a href=\"{route}\">{route}</a>.</p>");
break;
case "bmwt_response":
$keys = array_keys($array_params);
$values = array_values($array_params);
$this->email->Body = preg_replace($keys,$values,"{email_contents}");
break;
case "resetpassword":
$keys = array_keys($array_params);
$values = array_values($array_params);
$this->email->Body = preg_replace($keys,$values,"<p><strong>Beste {advisor},</strong></><p>Wij hebben een aanvraag ontvangen om het wachtwoord te hestellen. Ga naar <a href=\"{route}\">{route}</a> om een nieuw wachtwoord aan te maken.</p><p>Let op: deze link blijft 2 uur geldig.</p>");
break;
}
}
public function setReceiver($email_address)
{
$this->email->addAddress($email_address);
}
public function setFromAddress($email,$name=null)
{
$this->email->setFrom($email, $name);
$this->email->addReplyTo($email, $name);
}
public function sendEmail()
{
if( $this->email->send() ) return true;
else return false;
}
public function getBody()
{
return $this->email->Body;
}
}