0

こんにちは、私のメールは正常に動作していますが、html 形式のメールを送信する方法がわかりません。なぜなら、私は pear メールを使用しているためです! $to メールを送信したいメールIDを指定します.メールを送信するには、送信者メールであるメールのメールIDとパスワードを指定する必要があります.

<?php
if(isset($_POST['submit']))
{
require_once "Mail.php";//calling mail function


require_once 'Mail/mimePart.php';

    $from = "you@localhost.com";

    $to = "you@gmail.com";//your mail id

    $CompanyName = $_POST['CompanyName'];

    $mobile = $_POST['mobile'];


    $email  = $_POST['email'];

    $paddress = $_POST['paddress'];

    $subject = 'MOSONS Group';
    $message = 'PersonName: ' .$CompanyName. "\n";

    $message .= 'Mobile: ' .$mobile. "\n";

    $message .= 'Email: ' .$email. "\n";

    $message .= 'Message: ' .$paddress. "\n";

    $host="ssl://smtp.gmail.com";

    $port="465";

    $username="you@gmail.com";// your email id 

    $password="yourpassword"; //password

    $mime= "MIME-Version: 1.0\r\n";

    $type= "Content-type: text/html\r\n";

    $headers = array ('From' => $from,'To' => $to ,'Subject'=> 
$subject,'Mime'=> $mime,'Contenttype'=> $type);


    $smtp =@ Mail::factory('smtp',array ('host'=>$host,'port'=>$port,'auth'=>true,'username'=>$username,'password'=>$password));


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


    if(@PEAR::isError($mail)){
        echo ("<p>" .$mail->getmessage(). "</p>");
    }
    else
    {
        echo '<script type="text/javascript">alert("Thank You for Contacting us, our team will get in touch with you soon.!"); </script>';
    }
}
?>
4

1 に答える 1

1

ヘッダーを正しく設定していません。たとえば、あなたは次のようなことをしています

'Contenttype'=> 'Content-type: text/html';

それはちょうどあるはずです

'Content-Type' => 'text/html'

PEAR::Mail はひどくくだらないパッケージです。PHPMailer や Swiftmailer など、より優れたものに切り替える必要があります。

于 2013-10-10T14:19:01.677 に答える