0

该邮件程序可与 go daddy 一起使用,但我无法将其与家庭服务器一起使用。它将发送邮件并显示在收件箱中,但不显示内容。我认为这与使用 $body 标签有关,但我不确定有什么建议吗?

    <?php

// PHPmailer settings
$mail = new PHPMailer();  // create a new object
$mail->Issmtp(); // enable SMTP
$mail->SMTPDebug = 1;  // debugging: 1 = errors and messages, 2 = messages only
$mail->SMTPAuth = true;  // authentication enabled
$mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for GMail
$mail->Host = 'smtp.gmail.com';
$mail->Port = 465; 
$mail->Username = "email"; // SMTP username
$mail->Password = "password"; // SMTP password
$mail->From     = $email;
$mail->FromName = $contact_name;
$mail->SetFrom($email, $contact_name);
$mail->AddAddress('email');
$mail->Priority = 1;
$mail->WordWrap = 50;   // set word wrap
$mail->IsHTML(true);   // send as HTML
$mail->Subject  =  "Gray Gables maintenance request";
$mail->Body = $body;            
$mail->AltBody  =  "This is the text-only body";

// gets info from form
$name = $_POST['name'] ;
$email = $_POST['email'] ;
$phone = $_POST['phone'] ;
$message = $_POST['message'] ;
$ip = $_SERVER['REMOTE_ADDR'];




 // defines how message looks in email
$mail->Body="
Name: $name<br>
Telephone: $phone<br>
Email: $email<br>
IP address: $ip <br>
-------------------<br>
Message:<br>
$message";


// looks good in your inbox
$mail->From = "$email";
$mail->FromName = "$name"; 
$mail->AddReplyTo("$email","$name");



// gives success or error
if(!$mail->Send()) {
   echo 'Message could not be sent.';
       echo 'Mailer Error: ' . $mail->ErrorInfo;
   exit;
    }
    echo '
    <meta http-equiv="refresh" content="3;url=http/">
    <center><font size="5px">
    Message has been sent!!<br>
    you will be redirected to our home page in 3 seconds...<br>
    <a href="http">click here</a> to return now.

    </font>
    </center>
    ';

    ?>

    <?php
    echo ' Client IP: ';
    if ( isset($_SERVER["REMOTE_ADDR"]) )    {
    echo '' . $_SERVER["REMOTE_ADDR"] . ' ';
    } else if ( isset($_SERVER["HTTP_X_FORWARDED_FOR"]) )    {
    echo '' . $_SERVER["HTTP_X_FORWARDED_FOR"] . ' ';
    } else if ( isset($_SERVER["HTTP_CLIENT_IP"]) )    {
    echo '' . $_SERVER["HTTP_CLIENT_IP"] . ' ';
    }
    ?>
4

1 回答 1

0

我想你正在寻找这个...

$body = file_get_contents('yourfile.html');

您可以在“yourfile.html”中附加任何 HTML 内容,该内容会显示在您的邮件正文中。

于 2013-10-10T06:43:10.087 回答