用HTML发送电子邮件表单而看不到前景 [英] Sending email forms in HTML without seeing outlook

查看:74
本文介绍了用HTML发送电子邮件表单而看不到前景的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在探索邮寄表格的不同功能. (我们都不是HTML'ers,而是VB.net'ers.)

We are exploring different functions for mailing forms. (None of us are HTML'ers rather VB.net'ers.)

我发现并理解的代码如下

The code I found and understood is as follows

    <!DOCTYPE html>
<html>
<body>

<h3>Send e-mail to someone@example.com:</h3>

<form action="MAILTO:someone@example.com" method="post" enctype="text/plain">
Name:<br>
<input type="text" name="name" value="your name"><br>
E-mail:<br>
<input type="text" name="mail" value="your email"><br>
Comment:<br>
<input type="text" name="comment" value="your comment" size="50"><br><br>
<input type="submit" value="Send">
<input type="reset" value="Reset">
</form>

</body>
</html>

这将打开Outlook程序,用户必须单击Outlook中的发送/接收.

This opens the Outlook program and the user has to click send/receive in Outlook.

是否可以发送HTML格式的电子邮件表单而不显示上述示例中的Outlook程序?

Can I send email forms in HTML without displaying the Outlook program as in the above example?

推荐答案

在这里,我粘贴了完整的代码来发送邮件,而无需打开任何Outlook或使用gmail凭据等.它使用PHP来发送邮件.希望这对您有帮助.

Here i have pasted a complete code for sending mail without opening any outlook or using gmail credentials etc. It uses PHP for sending mail. hope this helps you.

if(isset($_POST['submit'])) {

if(trim($_POST['contactname']) == '') {
    $hasError = true;
} else {
    $name = trim($_POST['contactname']);
}

if(trim($_POST['subject']) == '') {
    $hasError = true;
} else {
    $subject = trim($_POST['subject']);
}

if(trim($_POST['ContactNum']) == '' && is_numeric($_POST['ContactNum'])) {
    $hasError = true;
} else {
    $Contacting = trim($_POST['ContactNum']);
}

//Check to make sure sure that a valid email address is submitted 
if(trim($_POST['email']) == '' && preg_match("/^([a-zA-Z0-9])+([a-zA-Z0-9\._-])*@([a-zA-Z0-9_-])+([a-zA-Z0-9\._-]+)+$/",$_POST['email']))  {
    $hasError = true;
}  else {
    $email = trim($_POST['email']);
}
if(trim($_POST['message']) == '') {
    $hasError = true;
} else {
    if(function_exists('stripslashes')) {
        $comments = stripslashes(trim($_POST['message']));
    } else {
        $comments = trim($_POST['message']);
    }
}

//----------------------Email Validation-----------------//
    function EmVal($e)
    {
        return preg_match("/^([a-zA-Z0-9])+([a-zA-Z0-9\._-])*@([a-zA-Z0-9_-])+([a-zA-Z0-9\._-]+)+$/",$e);
    }


//If there is no error, send the email
if(!isset($hasError)) {
        $emailTo = 'abc@abc.com';
        $body = "Name: $name \n\nEmail: $email \n\nSubject: $subject \n\nComments:\n $comments \n\nContact Number:\n $Contacting";
        $headers = 'From: WebBestow <'.$emailTo.'>' . "\r\n" . 'Reply-To: ' . $email;

        mail($emailTo, $subject, $body, $headers);
        $emailSent = true;}


}
 ?>

您可以根据需要添加字段.并设置action ="youpage.php".此代码应位于yourpage.php的html文档中

You can udpate fields as per your requirments. And set action="youpage.php". this code should be in html document of yourpage.php

这篇关于用HTML发送电子邮件表单而看不到前景的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆