Abd*_*lla 3 html forms email html-email
我使用简单的表单提交姓名电子邮件和电话号码.
我希望将这些详细信息发送到电子邮件ID,但它不会发送
有人请帮忙.
<form action="MAILTO:xyz@gmail.com?name=name&email=email" method="post" enctype="text/plain">
<tr>
<td width="336" height="148" colspan="9">
<input type="text" name="name" style="width:336; height:40; padding-left:10px" placeholder="Name" required>
<img src="images/spacer.gif" width="336" height="14" alt="">
<input type="email" name="email" style="width:336; height:40; padding-left:10px" placeholder="Email Id" required>
<img src="images/spacer.gif" width="336" height="14" alt="">
<input type="tel" name="name" style="width:336; height:40; padding-left:10px" placeholder="Contact Number" required>
</td>
</tr>
<tr>
<td width="186" height="65" colspan="7">
<a href="mailto:xyz@gmai.com"><input type="submit" value="Submit" style="width:186; height:65; background-color:black; color:white;"></a></td>
</tr>
</tr>
</form>
Run Code Online (Sandbox Code Playgroud)
这mailto:不是用于发送电子邮件,而是创建一个邮件,其中包含指定的收件人电子邮件mailto:receiver@abc.com.
例如:如果您使用的是Windows PC,并且如果您使用Outlook作为默认电子邮件软件,那么单击<a href="mailto:xyz@gmai.com">将在to字段中使用xyz@gmail.com打开Outlook .
如果要发送电子邮件,可以使用PHP邮件功能来执行此操作.
在表单操作而不是mail to function中添加您创建的PHP脚本文件并遵循此代码结构.
HTML:
<form method="post" action="your_php.php">
Receiver Email : <input type="text" name="to">
<input type="submit" value="sendMail">
</form>
Run Code Online (Sandbox Code Playgroud)
your_php.php脚本:
<?php
$to = $_POST['to'];
//Getting the 'to' textbox data from the form
/* If you are using GET method ,then use $_GET[] */
$subject = "Your Mail Subject" ;
$message = "Your message to be sent" ;
$headers = "From: yourmailid@domain.com" ;
// If you leave the $headers from field empty,then your server mail ID will be displayed
and it may be moved to the spam section of the email
mail($to,$subject,$message,$headers);
/* Done , Your mail will be sent to the email address you want
?>
Run Code Online (Sandbox Code Playgroud)
这会将邮件发送到所需的电子邮件地址.
PS PHP是一种服务器端脚本语言,所以除非你的网页和php脚本有托管服务器,否则你不能发送邮件.
| 归档时间: |
|
| 查看次数: |
2285 次 |
| 最近记录: |