1

我有一个名为contact.php的文件,里面有表格:

<form method="post" name="kontakt" action="send_mail.php">
  <fieldset class="formularz_kontaktowy">
    <legend>Formularz kontaktowy</legend>
    <div><label id="lblStatus"></label></div>
    <div><input type="text" name="txtName" title="Imię i nazwisko" id="txtName" class="text"></div>
    <div><input type="text" name="txtEmail" title="Email" id="txtEmail" class="text"></div>
    <div><input type="text" name="txtTitle" title="Tytuł" id="txtTitle" class="text"></div>
    <div><textarea cols="30" rows="10" name="txtMessage" id="txtMessage" class="text" title="Treść wiadomości"></textarea></div>
    <input type="submit" name="btnSendmail" value=Send">
  </fieldset>
</form>

发送邮件.php

<?php
  require_once "Mail.php";

    $from = "<mailaddress@gmail.com>";
    $to = "<mail2@gmail.com>";
    $subject = "Hi!";
    $body = "Hi,\n\nHow are you?";

    $host = "ssl://smtp.gmail.com";
    $port = "465";
    $username = "<mailaddress@gmail.com>";
    $password = "password";

    $headers = array ('From' => $from,
      'To' => $to,
      'Subject' => $subject);
    $smtp = Mail::factory('smtp',
      array ('host' => $host,
        'port' => $port,
        'auth' => true,
        'username' => $username,
        'password' => $password));

    $mail = $smtp->send($to, $headers, $body);

    if (PEAR::isError($mail)) {
      echo("<p>" . $mail->getMessage() . "</p>");
     } else {
      echo("<p>Message successfully sent!</p>");
     }

?>  

在浏览器中点击后btnSendmail,我有 URL,例如:localhost/contact.php?txtName=Mary+Smith&txtEmail=mailMail%40gmail.com&txtTitle=dfd&txtMessage=fgdf&btnSendmail=Send,但邮件没有发送,我没有消息。为什么?

4

2 回答 2

0

尝试改变

$username = "<mailaddress@gmail.com>";

$username = "mailaddress@gmail.com";
于 2012-06-14T15:37:48.100 回答
0

我发现了问题。我有两个标签,一个在模板中,第二个,嵌套在contact.php 中。非常感谢您的帮助。

于 2012-06-14T16:43:12.153 回答