Thanks for your remarks, DyDr.
The gmail is not the mail adres I'm using; just placed it here to fill in a mail adress other than mine.
This is the code so far, adjusted from all comments. Just the log.txt isn't working well (error 500).
How does it look to you?
Code:<?php function _log($log_file,$ip,$email,$message) { $str = date('Y-m-d H:i:s') . " IP:$ip, EM:$email, $message\r\n"; file_put_contents($log_file,$str,FILE_APPEND); } $log_file = 'http://www.domain.com/logs/log.txt'; $ip = $_SERVER['REMOTE_ADDR']; $website_naam = 'NAME WEBSITE'; $eigen_emailadres = 'bruno@domain.com'; $error_emailadres = 'bruno@domain.com'; $naam_verzender = 'Afzender'; $email_verzender = 'emailadres_van_verzender@zijn_domein.nl'; $bcc_emailadres = 'bruno@domain.com'; $html = true; $to = "bruno@domain.com"; $subject= "inschrijving"; $message = " Faciliteit: $_POST['faciliteit']; Naam bedrijf: $_POST['cmname']; Adres: $_POST['add']; $_POST['zip']; $_POST['city']; Beschrijving: $_POST['beschrijving']; Video: $_POST['socialURL']; Kernwoorden: $_POST['keywords1']; $_POST['keywords2']; $_POST['keywords3']; $_POST['keywords4']; $_POST['keywords5']; $_POST['keywords6']; Prijslijst: $_POST['prijslijst']; Openklikbare tekst: $_POST['klikbaar']; Contactpersoon: $_POST['name']; Telefoon: $_POST['phone']; Email: $_POST['email']; Website: $_POST['website']; Openingsuren: $_POST['openingsuren']; Facebook: $_POST['socialFB']; Instagram: $_POST['socialIN']; Twitter: $_POST['socialTW']; Google Plus: $_POST['socialGP']; Verdere opmerkingen: $_POST['opmerking']; "; $mime_boundary="==Multipart_Boundary_x".md5(mt_rand())."x"; $message = "This is a multi-part message in MIME format.\n\n" . "--{$mime_boundary}\r\n" . "Content-Type: text/plain; charset=\"utf-8\"\r\n" . "Content-Transfer-Encoding: 7bit\n\n" . $message . "\n\n"; foreach($_FILES as $userfile) { $tmp_name = $userfile['tmp_name']; $type = $userfile['type']; $name = $userfile['name']; $size = $userfile['size']; if (file_exists($tmp_name)) { if(is_uploaded_file($tmp_name)) { $file = fopen($tmp_name,'rb'); $data = fread($file,filesize($tmp_name)); fclose($file); $data = chunk_split(base64_encode($data)); } $message .= "--{$mime_boundary}\r\n" . "Content-Type: {$type};\r\n" . " name=\"{$name}\"\r\n" . "Content-Disposition: attachment;\r\n" . " filename=\"{$fileatt_name}\"\r\n" . "Content-Transfer-Encoding: base64\n\n" . $data . "\n\n"; } } $message.="--{$mime_boundary}--\r\n"; $headers = 'From: ' . $website_naam . ' <' . $eigen_emailadres . '>' . "\r\n"; $headers .= 'Reply-To: ' . $naam_verzender . ' <' . $email_verzender . '>' . "\r\n"; $headers .= 'Return-Path: Mail-Error <' . $error_emailadres . '>' . "\r\n"; $headers .= ($bcc_emailadres != '') ? 'Bcc: ' . $bcc_emailadres . "\r\n" : ''; $headers .= 'X-Mailer: PHP/' . phpversion() . "\r\n"; $headers .= 'X-Priority: Normal' . "\r\n"; $headers .= ($html) ? 'MIME-Version: 1.0' . "\r\n" : ''; $headers .= ($html) ? 'Content-type: text/html; charset=utf-8' . "\r\n" : ''; $headers .= ($html) ? "Content-Type: multipart/mixed;\r\n" . $headers .= ($html) ? "boundary=\"{$mime_boundary}\""; if(mail($to, $subject, $message, $headers)) { echo "Dankje om je gegevens door te zenden.<br>We nemen die door en contacteren je zo snel mogelijk."; _log($log_file,$ip,$email,'Mail call successful.'); } else { echo "Error in mail.<br>Probeer opnieuw door hieronder te klikken."; $last_error = error_get_last(); _log($log_file,$ip,$email,"Mail call failed - {$last_error['message']}"); } ?>



Reply With Quote

Bookmarks