Sending Mail with PHP
The most compatible way with either text/plain or text/html:
public function RegistrerSkjema() {
// Send a confirmation mail.
$headers = ''.
"From: ". $_POST['Navn'] ." <". $_POST['Epost'] ."> \r\n" .
"Reply-To: ". $_POST['Epost'] ." \r\n" .
"MIME-Version: 1.0 \r\n".
"Content-type: text/plain; charset=iso-8859-1 \r\n".
"X-Mailer: PHP/" . phpversion();
$ConfirmationMessage = ''.
'Navn: '. $_POST['Navn'] ."\r\n".
'E-Post: '. $_POST['Epost'] ."\r\n".
'Melding: '."\r\n\r\n".
$_POST['MerInfo'];
mail('a@domain.com,b@domain.com', 'Domain.com | Contact', $ConfirmationMessage, $headers);
return "<span style='color:green; font-weight:bold; font-size:24px'>Meldingen har blitt sendt.</span>";
}
If you need/want to specify reply parameter to the MTA (e.g. sendmail,postfix etc):
mail('a@domain.com,b@domain.com', 'Domain.com | Contact', $ConfirmationMessage, $headers, '-f noreply@thronic.com, -r noreply@thronic.com');
Additional tip for checking if e-mail is a real format or just BS
if (preg_match("/[a-zA-Z0-9\.]+?@[a-zA-Z0-9\.]+?\.[a-zA-Z0-9]+/", $_POST['Epost']) != 1) // Not valid e-mail address format given in contact form.