【发布时间】:2013-08-26 21:49:40
【问题描述】:
感谢您抽出宝贵时间查看我的问题。 我在 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>
【问题讨论】:
-
邮件服务器很复杂。 HTML 和 php 的这种混合并没有告诉我们我们需要知道什么。 Postfix 有很多配置需要正确完成
-
如果您要使用一些旧代码,请记住将结尾的分号与 Marc B 的答案放在一起。旧 =>
$to = "someone@somewhere"新 =>$to = "someone@somewhere.com"; -
@relentless 是的,我知道。 Mark B 的回答帮助了我的 php,但我仍然没有通过邮件功能发送电子邮件。反正我没想到会发生。我的 postfix 运行正常,我可以从命令行发送邮件,现在我只需要将两者链接起来。
-
@TylerDavis 不客气。