LampPi

 

Code


PHP: sendmail


...
$lp = new lamppi_class();
...

...
$email_type = "text";
$subject = "Public Contact Request";
$message = "Email: " . "\r\n" . $contact_email_address . "\r\n" . "\r\n";
$message .= "Subject: " . "\r\n" . $contact_email_subject . "\r\n" . "\r\n";
$message .= "Message: " . "\r\n" . $contact_email_message . "\r\n" . "\r\n";
$result = $this->sendMail($from, $to, $cc, $bcc, $reply_to, $email_type, $subject, $message);
if (!$result) {
# Error
$error = "Could not send the email";
}
...

private function sendMail($from, $to, $cc, $bcc, $reply_to, $email_type, $subject, $message) {
# Initialization
$error = "";
$header = "";

# Build header
$headers = "MIME-Version: 1.0" . "\r\n";
if ($email_type == "html") {
# html email
$headers .= "Content-type:text/html; charset=UTF-8" . "\r\n";
}else{
# text email
$headers .= "Content-type:text/plain; charset=UTF-8" . "\r\n";
}
if ($from) $headers .= "From: " . $from . "\r\n";
if ($cc) $headers .= "Cc: " . $cc . "\r\n";
if ($bcc) $headers .= "Bcc: " . $bcc . "\r\n";
if ($reply_to) $headers .= "Reply-To: " . $reply_to . "\r\n";

# Send email
$error = mail($to, $subject, $message, $headers);

# Exit
return $error;
}


About

Contact

Links

Site Map

© LampPi 2018