我正在使用此代码发送电子邮件:
$email="abc@gmail.com";
$to = $email;
$subject = "Test mail";
$message1 = '
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head></head>
<body>
<div style="width:80%;">
<table style="margin: 10px 20px 10px 20px;">
<tr><td>Hello!'." ".'</td></tr>';
$message1.=$mailmessage;
$message1.=
'<tr><td>Please find attachments for dailyreport.</td></tr>
<tr><td><br>' . "Thanks and Regards with ". '</td></tr>
</table></div>
</body>
</html>';
$from = "admin@feed.com";
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
$headers .= 'From: ' . $from . "\r\n";
if(mail($to,$subject,$message1,$headers)) {
"mail sent";
} else {
"email does not exist";
}
要发送附件,我需要将内容类型更改为Content-Type: multipart/mixed;\n
. 但是 HTML 上下文会改变。如何将文件附加到此 html?