3

我正在使用 Cakephp 功能将邮件内容发送到 iPhone 手机。邮件成功发送到 iPhone,但他们收到的内容格式不均。

示例:我的内容

  Username:siddesh
  Date:2013-06-20 04:46:40
  Email:siddesh@bhalke.com
  Type:seller
  File Name:xlsfile
  File Type:xls
  Uploaded By:primary User
  Download :[download]

我的代码:

  <p>Username:<?php echo htmlspecialchars($username);?></p>
  <p>Date:<?php echo htmlspecialchars($date);?></p>
  <p>Email:<?php echo htmlspecialchars($email);?></p>
  <p>Type:<?php echo htmlspecialchars($type);?></p>
  <p>File Name:<?php echo htmlspecialchars($file_name);?></p>
  <p>File Type:<?php echo htmlspecialchars($file_type);?></p>
  <p>Uploaded By:<?php echo htmlspecialchars($uploaded_by);?></p>
  <p><a href="<?php echo 'http://www.test.com/files/'.$uid.'/'.$file_name.'.'.$file_type;?>">Download</a></p><br/> 

应该收到格式:

  Username:siddesh
  Date:2013-06-20 04:46:40
  Email:siddesh@bhalke.com
  Type:seller
  File Name:xlsfile
  File Type:xls
  Uploaded By:primary User
  Download :[download]

但它在 iPhone 上收到 Format as: SUBJ:test-failed file

MSG:¿¿¿¿¿¿                                                   





(Con't) 2 of 6




(Con't) 3 of 6






Username:Rajesh:2013-06-17
10:05:14Email:sid@r

(Con't) 4 of 6

mygroup.comType:MyFile
Name:simple Type:xlsUploaded By:Sid blk
ConnectionThank

(Con't) 5 of 6

You,test.com





    A¿ Copyright
2013 by test. All Right Reserved.


  info@test.com

  www.test.com 

发送邮件功能..!

    function sendMail($template = null, $to_email = null, $from_email = null, $subject = null, $contents = array()) {


    $from_email = Configure::read('site.support_email');
    $bcc_email = Configure::read('site.developers_email');

    $email = new CakeEmail();
    $result = $email->template($template, 'default')
            ->emailFormat('html')
            ->to($to_email)
            ->bcc($bcc_email)
            ->from($from_email)
            ->subject($subject)
            ->viewVars($contents);

    if ($email->send('default')) {
        $this->log('email to :  '  .$to_email. 'Subject :  '   .$subject);  
        return true;
    }
    return false;

}

为了发送上述格式的数据,我使用了普通pbr标签,但 iPhone 上显示的数据格式不正确,并且发送了一些不必要的数据。

有人可以帮我吗?

4

1 回答 1

0

以 HTML 格式发送邮件,而不是像这样的文本:

//Send as 'html', 'text' or 'both' (default is 'text')
$this->Email->sendAs = 'both';
于 2013-06-21T13:05:50.470 回答