这是发送邮件的PHP代码:
<?php
require("smtp.php");
##########################################
$smtpserver = "smtp.163.com";//SMTP服务器
$smtpserverport = 25;//SMTP服务器端口
$smtpusermail = "[email protected]";//SMTP服务器的用户邮箱
$smtpemailto = "[email protected]";//发送给谁
$smtpuser = "[email protected]";//SMTP服务器的用户帐号
$smtppass = "xxxxx";//SMTP服务器的用户密码
$mailsubject = "";//邮件主题
$mailbody = "<h1></h1>";//邮件内容
$mailtype = "HTML";//邮件格式(HTML/TXT),TXT为文本邮件
##########################################
$smtp = new smtp($smtpserver,$smtpserverport,true,$smtpuser,$smtppass);
//这里面的一个true是表示使用身份验证,否则不使用身份验证.
$smtp->debug =false;//是否显示发送的调试信息
$smtp->sendmail($smtpemailto, $smtpusermail, $mailsubject, $mailbody, $mailtype);
?>
上面的代码都可以执行,但是只能发送固定的内容($mailsubject = "";//邮件主题
$mailbody = "<h1></h1>";//邮件内容) .每次都要在代码内输入主题和内容,现在想把下面的这段HTML代码嵌入到到PHP代码里,实现一个发送邮件的页面,应该如何实现呢?<html>
<head>
<title>sendmail</title>
</head>
<body>
<form method="post"  action="smtp.php" name="form1" enctype="multipart/form-data"
onsubmit="return sendmail();">
<table width="100%" cellpadding="1" cellspacing="0" border="0" style="display:block;z-index:10;filter:alpha(opacity=100);">
<tr>
<td>发给:</td>
<td><input type="text"  id="receiver"  size="50" title="要发给谁啊?" maxlength="255"    value=""   >
<input type="hidden" name="receiver_id" value="" >
<select name="receiverType" size ="1" onchange="sendobject(this.options[this.selectedIndex].value);">
<option value = "0" >所有人员</option>
<option value = "1" >组</option>
<option value = "2" >个人</option>
</select>
<tr>
<td>主题:</td>
<td><input type="text" value="" name="subject"  size="50" title="主题" maxlength="255"    value=""  >
</td>
</tr>
<tr><td><span id="addfile" onclick="addfile()" style="cursor:pointer;">添加附件</span></td>
<td><div id="filebox">
</div></td></tr>
<tr><td>内容</td><td>
<iframe src="http://mimg.163.com/jsstyle/HtmlEditor/htmltool.htm"  name="htmlletter" style="height:321px; width:100%;" scrolling="no" border="0" frameborder="0" tabindex="3" ></iframe>
<input type="hidden" name="body" value="" >
</td></tr>
<tr><td colspan="2">
<input type="submit" value="发送" title="发送邮件"  name="sendmail">
<input type="hidden" name="mod" value="send" >&nbsp;
<input type="button" value="取消" title="取消" onclick="clearLink();"></td></tr></table>
</form>
</body>
</html>