0

我正在尝试制作一个 html 和 php 反馈表,我收到一封如下所示的电子邮件:

New contact form submission 
From:,, 
Email:,@email, 
,,

我的html是:

<form method="POST" action="contactform.php">
    Name:<br/>
        <input type="text" name="name" />
        <br/><br/>
    EMail:<br/>
        <input type="text" name="email" />
        <br/><br/>
    Message: <br/>
        <textarea name"message" rows="10" cols="50" />
        </textarea><br/>
    <input type="submit" value="submit" />
</form>

我的PHP是:

<?php
//converting veriables
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$recipient = 'nicholasparry@me.com'; 
$subject="Contact Form"; 
//creating message
$content = "New contact form submission \n From:,$name, \n Email:,@email, \n ,$message,"; 
//sending message
mail($recipient, $message, $content);
?>

谁能帮我解决问题?

4

3 回答 3

4

它的:

$content = "New contact form submission \n From: ".$name.",\n Email: ".$email.", \n Message: ".$message;

<textarea name="message" rows="10" cols="50"></textarea>
于 2012-09-20T08:02:18.807 回答
0

开始使用SwiftmailerPhpMailer,你的生活会更轻松...

Swiftmailer 示例:

require_once 'lib/swift_required.php';
$transport = Swift_MailTransport::newInstance();
$mailer = Swift_Mailer::newInstance($transport);
$message = Swift_Message::newInstance('Wonderful Subject')
    ->setFrom(array('john@doe.com' => 'John Doe'))
    ->setTo(array('receiver@domain.org', 'other@domain.org' => 'A name'))
    ->setBody('Here is the message itself');
$mailer->send($message);

PhpMailer 示例:

$mail             = new PHPMailer(); // defaults to using php "mail()"
$mail->SetFrom('name@yourdomain.com', 'First Last');
$mail->AddReplyTo("name@yourdomain.com","First Last");
$mail->AddAddress("whoto@otherdomain.com", "John Doe");
$mail->Subject    = "PHPMailer Test Subject via mail(), basic";
$mail->AltBody    = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
$mail->MsgHTML($body);
$mail->AddAttachment("images/phpmailer.gif");      // attachment
$mail->AddAttachment("images/phpmailer_mini.gif"); // attachment
if(!$mail->Send()) {
    echo "Mailer Error: " . $mail->ErrorInfo;
} else {
    echo "Message sent!";
}

我更喜欢 Swiftmailer,但你选择你最好的选择 ;-)

于 2012-09-20T08:08:25.983 回答
0

将变量名用大括号括起来。例如“发件人:,{$name}”,

于 2012-09-20T08:21:51.433 回答