Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/76.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用php和postfix发送邮件_Php_Html_Email - Fatal编程技术网

使用php和postfix发送邮件

使用php和postfix发送邮件,php,html,email,Php,Html,Email,感谢您抽出时间回顾我的问题。 我在Centos 6.4上安装了postfix。我不太熟悉电子邮件服务器或PHP,但我想设置一个简单的场景,使用postfix发送电子邮件。有人告诉我应该使用php。我现在的工作。(不工作)源代码是这 <!doctype html> <html> <head> <style type="text/css"> #mainContainer { position: absolute; top

感谢您抽出时间回顾我的问题。 我在Centos 6.4上安装了postfix。我不太熟悉电子邮件服务器或PHP,但我想设置一个简单的场景,使用postfix发送电子邮件。有人告诉我应该使用php。我现在的工作。(不工作)源代码是这

<!doctype html>
<html>
<head>
<style type="text/css">
#mainContainer
{
        position: absolute;
        top: 0;
        right: 0;
        bottom: 0;
        left: 0;
}

#adressContainer
{
        width:100%;
        height:3%;
}

#buttonContainer
{
        width:100%;
        height:5%;
}

#bodyContainer
{
        width:100%;
        height:90%;
}

#address
{
        resize:none;
        width:100%;
        height:100%;
}

#bodyText
{
        resize:none;
        width:100%;
        height:100%;
}
</style>
<script>

        <?php
        function sendMail()
        {

                $to = "someone@somewhere"
                $subject = "Test mail";
                $message = "Hello! This is a simple email message.";
                $headers = "From:" . $from;
                mail($to,$subject,$message,$headers);
        }       
        ?>
</script>
<!--<link rel="stylesheet" type="text/css" href="email.css" />-->
</head>
<body>
        <div id="mainContainer">
                <div id="addressContainer">
                        <input id="adress" type="text" name="Adress: "></input>
                </div>

                <div id="buttonContainer">
                        <button type="submit" onclick="sendMail()">send</button>
                </div>

                <div id="bodyContainer">
                        <textarea id="bodyText">I love you whitney :) </textArea>
                </div>
        </div>
</body>
</html>

#主容器
{
位置:绝对位置;
排名:0;
右:0;
底部:0;
左:0;
}
#地址容器
{
宽度:100%;
身高:3%;
}
#钮扣容器
{
宽度:100%;
身高:5%;
}
#集装箱
{
宽度:100%;
身高:90%;
}
#地址
{
调整大小:无;
宽度:100%;
身高:100%;
}
#正文
{
调整大小:无;
宽度:100%;
身高:100%;
}
发送
我爱你惠特尼:)

PHP在服务器上运行
onClick
客户端计算机上执行Javascript。您可以通过Javascript代码而不是直接调用PHP函数,反之亦然

您正在做的事情可以通过一个简单的形式完成:

<?php

if ($_SERVER["REQUEST_METHOD"]  == 'POST') {
    $to = $_POST['to'];
    $text = $_POST['text'];
    mail($to, .....);
}

?>
<form method="POST" action="">
    <input type="text" name="to" />
    <input type="text" name="text" />
    <input type="submit" />
</form>


根本不需要使用Javascript。

邮件服务器很复杂。HTML和php的混合并没有告诉我们需要知道什么。Postfix有很多配置需要正确完成。如果你打算使用一些旧代码,请记住将结尾分号与Marc B的答案放在一起。旧=>
$to=”someone@somewhere“
new=>
$to=”someone@somewhere.com";@无情是的,我知道。Mark B的anwer帮助我使用php,但我仍然没有通过邮件功能发送电子邮件。我没想到会发生这种事。我的postfix运行正常,我可以从命令行发送邮件,现在我只需要将两者链接起来。@TylerDavis不客气。