58 lines
1.8 KiB
PHP
58 lines
1.8 KiB
PHP
<?php
|
|
class email {
|
|
// Reciever - String var
|
|
// Format: "email@adresa.cz"
|
|
public $reciever = null;
|
|
// Sender - string var
|
|
// Format: "Zobrazene Jmeno <email@adresa.cz>"
|
|
public $sender = null;
|
|
// ReplyTo - string var
|
|
// Format: "email@adresa.cz"
|
|
public $replyTo = null;
|
|
// CarbonCopies - string array
|
|
// Format: array("email@adresa.cz", "email@adresa.cz", ...)
|
|
public $cc = null;
|
|
// Subject - string var
|
|
// Format: "Some String"
|
|
public $subject = null;
|
|
// MailContent - string var
|
|
// Format: "Some String"
|
|
public $content = null;
|
|
// headers - string var
|
|
// Is built by setHeader() function
|
|
private $headers = "";
|
|
|
|
public function setHeaders() {
|
|
if(isset($this->sender) ) {
|
|
$this->headers .= "From: " . $this->sender . PHP_EOL;
|
|
} else {
|
|
echo "WARN: From(sender) is not set!";
|
|
}
|
|
|
|
if(isset($this->replyTo) ) {
|
|
$this->headers .= "Reply-To: <" . $this->replyTo . ">" . PHP_EOL;
|
|
} else {
|
|
echo "WARN: Reply-To is not set!";
|
|
}
|
|
|
|
foreach($this->cc as $x) {
|
|
$this->headers .= "Bcc: " . $x . PHP_EOL;
|
|
}
|
|
$this->headers .= "X-Mailer: PHP/" . phpversion() . PHP_EOL;
|
|
$this->headers .= "X-Priority: 2" . PHP_EOL;
|
|
$this->headers .= "MIME-Version: 1.0" . PHP_EOL;
|
|
$this->headers .= "Content-Type: text/html; charset=utf-8" . PHP_EOL;
|
|
|
|
}
|
|
|
|
public function sendMail() {
|
|
if(isset($this->reciever) && isset($this->subject) && isset($this->content)) {
|
|
mb_send_mail($this->reciever, $this->subject, $this->content, $this->headers);
|
|
} else {
|
|
echo "ERR: mail reciever/subject/content is not set!";
|
|
}
|
|
}
|
|
}
|
|
|
|
|