我有以下80.php的代码。当我访问此页面时,它显示“消息已成功发送”。但我没有收到电子邮件。我确认我的文件3.JPG也存在于正确的文件夹中。是什么原因;
这是页面:http://raveen.comlu.com/80.php
<?php
$to = "raveen_chandra@yahoo.com";
$subject = "New attachment message";
$msg = "This is headline";
$msg .= "This is my first attachment example\n";
$msg .= "This is HTML messageb with an attachment";
$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
$uid = md5( uniqid(time()) ); //a random hash will be necessary to send mixed content ???????
$filename = basename( $fileatt );
//main header (multipart mandatory)
$header = "From: Raveen <raveen1231@gmail.com> \r\n";
$header .= "Cc: raveen749@gmail.com \r\n";
$header .= "Bcc: raveen678@gmail.com \r\n";
//$header .= "Reply-to: support@company.com \r\n";
$header .= "MIME-Version: 1.0 \r\n";
$header .= "Content-type: multipart/mixed; boundary=\"". $uid. "\"\r\n\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 = "--". $uid. "\r\n";
$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: application/octet-stream; name\"". $filename. "\"\r\n";
$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!";
}
&GT;