-1
Mein Webserver unterstützt mail() -Funktion. Ich sehe keine Fehler. Aber meine E-Mail erhält die E-Mail nicht. Ich habe so viele Dinge in SO und Google ausprobiert.PHP-Mail mit Anhang keine Fehler
<?php
//error_reporting(-1);
//ini_set('display_errors', 'On');
//set_error_handler("var_dump");
$to = "[email protected]";
$subject = "New attachment message";
$msg = "This is headline";
$message .= "This is my first line of text.\nThis is my second line of text";
$fileatt = "uploads/3.JPG";
$fo = fopen($fileatt, 'r');
$data = fread($fo, filesize($fileatt)); //read entire file
fclose($fo);
$data = chunk_split(base64_encode($data)); //?????? what is chunk_split and base64_encode
//generate a boundary
$uid = md5(uniqid(time())); //md5() is used to create unique number
$filename = basename($fileatt);
//main header (multipart mandatory)
$header = "From: Raveen Chandra <[email protected]> \r\n";
//$header .= "Cc: [email protected] \r\n";
//$header .= "Bcc: [email protected] \r\n";
//$header .= "Reply-to: [email protected] \r\n"; //can be same address as From header or other
$header .= "MIME-Version: 1.0 \r\n";
$header .= "Content-type: multipart/mixed; boundary=\"". $uid. "\"\r\n"; //to send an email with attachment, we need to use the multipart/mixed MIME type
//it specifies that mixed types will be included in the email
/* message and attachment - message and attachment sections can be specified within boundaries.
*/
$message = "--". $uid. "\r\n"; //boundary starts with two hyphens, followed by a unique number
$message .= "Content-type: text/plain; charset=iso-8859-1\r\n"; //Content-type: text/plain;
$message .= "Content-Transfer-Encoding: 7bit\r\n\r\n";
$message .= $msg. "\r\n\r\n";
$message .= "--". $uid. "\r\n"; //When sending multiple attachments, separate MIME parts with this
$message .= "Content-type: image/jpeg; name\"". $filename. "\"\r\n"; //use different content types here
$message .= "Content-Transfer-Encoding: base64\r\n";
$message .= "Content-Disposition: attachment; filename=\"". $filename. "\"\r\n\r\n";
$message .= $data. "\r\n\r\n";
$message .= "--". $uid. "--"; //after the final MIME part
if(mail($to, $subject, $message, $header)){
echo "Message sent successfully";
}
else{
echo "Message could not be sent!";
}
?>
Kommentieren Sie die ersten drei Zeilen, um zu überprüfen, welchen Fehler Sie erhalten "error_reporting (E_ALL); ini_set ('display_errors', 1);' –
@Uchiha, Sir, ich habe nicht abgehakt. Dann habe ich viele fehlervolle Seiten schwer zu lesen bekommen. eine Sache ... int (8) string (27) "Undefinierte Variable: Nachricht" string (33). dann korrigiere ich :) dann bekomme ich keine fehler mehr. aber ich bekomme immer noch keine E-Mail – Tina
Ich verstehe nicht. Es tut uns leid. Was tue ich? Erzähl es mir bitte – Tina