2016-06-21 107 views
0

我一直在使用公司扩展名单。唯一不起作用的是管理员在扩展列表中的表单上添加新用户时,我希望它通过电子邮件将表单详细信息发送给我的老板,这样每次有人添加他都知道。php邮件正文问题

我读了一点,因为我很新的PHP,但我发现这个mailto html命令,它很好地把主题行和正确的电子邮件地址,但身体看起来很可怕。所有混合起来是这样的:

name:jurgen&extension number:242&email:[email protected]&mode=added 

我读到了关于PHP脚本的电子邮件,但我很困惑如何做到这一点。有人能告诉我一种方法来实现这一点吗?我希望第一个按钮发送电子邮件,然后必须显示第二个按钮以将数据添加到数据库中。

我当前的代码:

<form name="form1" action="<?=$_SERVER['PHP_SELF'];?>?mode=added" method="post"> 
<div align="center"><table class="searchable"> 
<tr><td>Extension:</td><td><div align="center"> 
<input type="text" name="ext" required /> 
<span class="error">* <?php echo $nameErr;?></span> 
</div></td></tr> 
<tr><td>Name:</td><td><div align="center"> 
<input type="text" name="name" required /> 
<span class="error">* <?php echo $nameErr;?></span> 
</div></td></tr> 
<tr><td>Department:</td><td><div align="center"><select name="department" required> 
      <option value="VW NEW CARS ADMIN AND STOCK CONTROL">Value 4</option> 
      <option value="value 5">value 5</option> 
      <option value="value 6">value 6</option> 
      <option value="value 3">value 3</option> 
      <option value="value 4">value 4</option> 
    </select> 
<span class="error">* <?php echo $nameErr;?></span> 
</div></td></tr> 
<tr><td>Email:</td><td><div align="center"> 
<input type="text" name="email" pattern="[a-z0-9._%+-][email protected][a-z0-9.-]+\.[a-z]{2,3}$" name="email" title="Example: [email protected]" required/> 
<span class="error">* <?php echo $nameErr;?></span> 
</div></td></tr> 
<tr><td>Cellphone:</td><td><div align="center"> 
<input type="text" name="phone" /> 
</div></td></tr> 
<tr><td colspan="2" align="center">| <button type="submit" formaction="mailto:[email protected]?subject=New User Added To Extension List" enctype="text/plain" method="get">Email Boss</button> 
<tr><td colspan="2" align="center"><a href="javascript:history.go(-1);">Back</a> | <input type="submit" name="submit" id="submit" value="Add New Contact"<?php if($disable ==1){?>disabled<?php } ?>/></td></tr> 
<input type="hidden" name="mode" value="added"> 
+0

请添加您的尝试并编辑您的问题。 – limonik

+0

你的问题到底是什么? – Gideon

+0

@limonik编辑先生 – 5ilent

回答

1

如果你想在你的电子邮件使用HTML建立了良好的机身设计, 例如:

        $to = $email; 
           $message = " 
           <table width='100%' border='0' cellspacing='0' cellpadding='3'> 
            <tr> 
            <td colspan=2><b>SignalShare</b></td> 
            </tr> 
            <tr> 
            <td colspan=2>Thank you for creating an account.</td> 
            </tr> 
            </table> 
            <hr><h3>Account info</h3><hr> 
            <table width='100%' border='0' cellspacing='0' cellpadding='3'> 
            <tr> 
            <td width='28%' >Username : </td> 
            <td width='72%'>".$username."</td> 
            </tr> 
            <tr> 
            <td>Email : </td> 
            <td>".$email."</td> 
            </tr> 
           </table> 
           <p>SignalChat advise you not to delete this email for it contains informations that could be in use later.</p> 
            <hr><h3>Account activation</h3><hr> 
            <p>If you wish to activate your account please use the following link : </p> 
            <p><a href = 'localhost/SignalShare/activate.php?code=$code&user=$username' style = 'text-decoration: none; color: blue;' >Activate account</a></p> 
            <hr> 
            <p>If this email does not concern you please ignore it.</p> 
            <p>All regards.</p> 
            <p>SignalShare.</p> 
            "; 
           $subject = "Accout activation";         
           $headers = "From: SignaShare\r\n"; 
           $headers .= "Content-type: text/html\r\n"; 

           mail($to, $subject, $message, $headers);   
           header("Location: success.php?email=".$email.""); 

正如你可以看到我使用的表和html标签来帮助整理电子邮件,并且如果您在$标头中注意到我添加了$ header。=“Content-type:text/html \ r \ n”;
如果这不是你所要求的,请在这里留言,所以我可以编辑我的答案,祝你好运