1

プレーン テキストは送信できますが、HTML は送信できません。メールが受信されない理由を教えてください。事前に THX :) コードは次のとおりです。

  $mailBody ='<table width="100%" >
  <tr>
  <td>   
            <img src="MailerImages/img_logo.gif"  alt="UrMint.com"/>
            <h1 style="font:bold 20px tahoma; color:#808080;">Hi #USERNAME,</h1>
            <p style="font:13px tahoma; color:#666666; line-height:25px;">


             Your password for xyzacccount associated with mobile no password #MOBNO is : <strong style="color:#e65786;">#PASSWORD</strong>
            <br />
            If you didn\'t request a new password, let us know immediately.  
            <br />
            This message was sent from xyz.com at your request.
            </p>

            <strong style="font:bold 13px tahoma; color:#666666;  line-height:25px;">
            Happy Learning ,
            <br />
            The <span style="color:#42b1d6;">Ur</span><span style="color:#e65786;">urMint</span> Team
            </strong>
        </table>    

            ';
            echo  $mailBody;
        SendEMail_fun('xyz@gmail.com', $mailBody,'sub','xyzsender','xyz@rediffmail.com');   

function SendEMail_fun($strEmailTo,$strEmailBody,$strSubject,$SenderName = '',$SenderEmail='')
{
global $SwiftMessage; $SenderName = $SenderName <> ''?$SenderName:"support@xyz.com";

        $SenderEmail    =   $SenderEmail <> ''?$SenderEmail:"support@xyz.com";

        $email_from_name = $SenderName." <".$SenderEmail.">";


        $email_from_mail = $SenderEmail;
        $email_to_bcc= "";
        $email_to= $strEmailTo;
        $email_subject= $strSubject;

        $emailbody =$strEmailBody;

        try
        {  

            require_once ("lib/Swift.php");


            $smtp = new Swift_Connection_SMTP("localhost", 25);


            $swift = new Swift($smtp);

            $message = new Swift_Message($email_subject, $emailbody, "text/html");
            $message->setFrom($email_from_name);
            $message->setReplyTo($email_from_mail);
            $message->setBcc($email_to_bcc);


            if ($swift->send($message, $email_to, $email_from_mail))
            {
                //echo "Message sent";
                 echo  $SwiftMessage = 'Message Sent';
                return true;
            }
            else
            {
                //echo "Message failed to send";
                 echo  $SwiftMessage = 'Message failed to send';
                return false;
            }
            $swift->disconnect();
            return true;
        }
        catch (Swift_ConnectionException $e)
        {
            //          echo "There was a problem communicating with SMTP: " . $e->getMessage();
             echo  $SwiftMessage = "There was a problem communicating with SMTP: " . $e->getMessage();
            return false;
        } 
        catch (Swift_Message_MimeException $e)
        {
            //    echo "There was an unexpected problem building the email:" . $e->getMessage();
            echo  $SwiftMessage = "There was an unexpected problem building the email:" . $e->getMessage();
            return false;
        }

    }
4

1 に答える 1

0

あなたのメールが送信されない正確な理由はわかりません。私がいつも使用している HTML 電子メール スクリプトを含めました。それが役に立てば幸い。

<?php
$myFile = "email.html";
$fh = fopen($myFile, 'r');
$htmlemail = fread($fh, filesize($myFile));
fclose($fh);


$to = "YOUREMAIL@gmail.com" . ",";
//$to .= "@gmail.com" . ",";

$subject = "SUBJECT";

$message = $htmlemail;

$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1" . "\r\n";


$headers .= 'From: NAME <email@email.com>' . "\r\n";


// Mail it
mail($to, $subject, $message, $headers);

?>

通販がうまくいくかどうかに影響を与えるかどうか疑問に思っています:

あなたが持っている if ($swift->send($message, $email_to, $email_from_mail))

私の: mail($to, $subject, $message, $headers);

試してみる価値

于 2013-09-10T16:16:07.820 に答える