html mailto 不发送电子邮件
html mailto not sending email
我正在使用一个简单的表格来提交姓名电子邮件和 phone 电话号码。
我希望将这些详细信息发送到电子邮件 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>
mailto:
是一个方案前缀,用于将 link 标识为电子邮件地址,为客户端打开默认电子邮件应用程序,即您不应将其用作 action
表单的属性。
您需要 POST 将数据发送到服务器端脚本并使用它来发送数据,例如 PHP 的 mail() 函数,假设您有服务器设置这样做。
mailto:
不用于发送电子邮件,而是会使用 mailto:receiver@abc.com
中指定的收件人电子邮件创建邮件。
例如:
如果您有一台 windows PC,并且如果您将 Outlook 作为默认电子邮件软件,则单击 <a href="mailto:xyz@gmai.com">
将打开带有 xyz@gmail.com[= 的 outlook 34=] 在 到 字段中。
如果您想发送电子邮件,可以使用 PHP 邮件功能来完成。
在表单操作而不是邮件功能中添加您创建的 PHP 脚本文件并遵循此代码结构。
HTML :
<form method="post" action="your_php.php">
Receiver Email : <input type="text" name="to">
<input type="submit" value="sendMail">
</form>
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
?>
这会将邮件发送到所需的电子邮件地址。
P.S。
PHP 是一种服务器端脚本语言,因此除非您有网页托管服务器和 php 脚本,否则您无法发送邮件。
如果我没理解错的话,您希望将所有内容放在一页中并从同一页执行。
您可以使用以下代码从单个页面发送邮件,例如 index.php 或 contact.php
这个答案和我原来的答案之间的唯一区别是动作留空的地方。
最好用header('Location: thank_you.php');而不是在 PHP 处理程序中回显以将用户重定向到另一个页面。
将下面的全部代码复制到一个文件中。
<?php
if(isset($_POST['submit'])){
$to = "xyz@gmai.com"; // this is your Email address
$from= $_POST['email']; // this is the sender's Email address
$name = $_POST['name'];
$subject = $_POST['contactnumber'];
$message = $name . " Contact Number:" . "\n\n" . $_POST['contactnumber'];
$headers = "From:" . $from;
mail($to,$subject,$message,$headers);
echo "Mail Sent. Thank you " . $name . ", we will contact you shortly.";
// You can also use header('Location: thank_you.php'); to redirect to another page.
}
?>
<!DOCTYPE html>
<head>
<title>Form submission</title>
</head>
<body>
<form action="" method="post">
<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="contactnumber" 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>
</body>
check more in this question
我正在使用一个简单的表格来提交姓名电子邮件和 phone 电话号码。
我希望将这些详细信息发送到电子邮件 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>
mailto:
是一个方案前缀,用于将 link 标识为电子邮件地址,为客户端打开默认电子邮件应用程序,即您不应将其用作 action
表单的属性。
您需要 POST 将数据发送到服务器端脚本并使用它来发送数据,例如 PHP 的 mail() 函数,假设您有服务器设置这样做。
mailto:
不用于发送电子邮件,而是会使用 mailto:receiver@abc.com
中指定的收件人电子邮件创建邮件。
例如:
如果您有一台 windows PC,并且如果您将 Outlook 作为默认电子邮件软件,则单击 <a href="mailto:xyz@gmai.com">
将打开带有 xyz@gmail.com[= 的 outlook 34=] 在 到 字段中。
如果您想发送电子邮件,可以使用 PHP 邮件功能来完成。
在表单操作而不是邮件功能中添加您创建的 PHP 脚本文件并遵循此代码结构。
HTML :
<form method="post" action="your_php.php">
Receiver Email : <input type="text" name="to">
<input type="submit" value="sendMail">
</form>
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
?>
这会将邮件发送到所需的电子邮件地址。
P.S。 PHP 是一种服务器端脚本语言,因此除非您有网页托管服务器和 php 脚本,否则您无法发送邮件。
如果我没理解错的话,您希望将所有内容放在一页中并从同一页执行。
您可以使用以下代码从单个页面发送邮件,例如 index.php 或 contact.php
这个答案和我原来的答案之间的唯一区别是动作留空的地方。
最好用header('Location: thank_you.php');而不是在 PHP 处理程序中回显以将用户重定向到另一个页面。
将下面的全部代码复制到一个文件中。
<?php
if(isset($_POST['submit'])){
$to = "xyz@gmai.com"; // this is your Email address
$from= $_POST['email']; // this is the sender's Email address
$name = $_POST['name'];
$subject = $_POST['contactnumber'];
$message = $name . " Contact Number:" . "\n\n" . $_POST['contactnumber'];
$headers = "From:" . $from;
mail($to,$subject,$message,$headers);
echo "Mail Sent. Thank you " . $name . ", we will contact you shortly.";
// You can also use header('Location: thank_you.php'); to redirect to another page.
}
?>
<!DOCTYPE html>
<head>
<title>Form submission</title>
</head>
<body>
<form action="" method="post">
<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="contactnumber" 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>
</body>
check more in this question