【问题标题】:How to Send proper html data to iphone from php?如何从 php 向 iphone 发送正确的 html 数据?
【发布时间】:2013-06-21 12:59:09
【问题描述】:

我正在使用 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 上收到的格式为: SUBJ:测试失败的文件

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;

}

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

谁能帮我解决这个问题?

【问题讨论】:

  • @AD7six:检查我已经编辑了我的问题..!!
  • //作为'html'、'text'或'both'发送(默认为'text') $this->Email->sendAs = 'both'; // 因为我们喜欢发送漂亮的邮件
  • @AD7six : 现在我添加了代码,请检查一下,我该如何修复它..!!
  • @AD7six:现在我已经写完了,现在你能帮我吗?
  • @SiddeshBhalke 不可能说 - 如何重现您的问题?所有这些额外的文本在哪里定义?原始电子邮件内容是什么样的(您可能需要在不同的客户端中阅读邮件才能获得此内容)?

标签: php iphone cakephp


【解决方案1】:

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

//Send as 'html', 'text' or 'both' (default is 'text')
$this->Email->sendAs = 'both';

【讨论】:

  • KAsh:我已经添加了我的代码,我在哪里可以编辑它,请建议..!!
  • 除了不是将其作为 html 发送 - 它以 html 和 文本的形式发送(顺便说一句,这是一个很好的做法)但是它在这里看起来不相关 - 从问题,它已经作为 html 发送。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2022-08-19
  • 1970-01-01
  • 2017-12-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多