如何通过电子邮件分享通行证

时间:2013-03-28 06:41:30

标签: web-services ios6 passbook

我创建了一个传递,可以通过MAMP中的应用程序或Web服务器添加它。如何通过电子邮件分享,我该如何分享?

2 个答案:

答案 0 :(得分:0)

这样的事情应该可以解决问题。请注意,MIME类型必须为application/vnd.apple.pkpass,以便设备将其识别为Passbook传递。

$pass = "pass.pkpass";
$path = "/path/to/pass/";
$from_name = "smallgirl";
$from_mail = "smallgirl@smallgirl.co.kr";
$reply_to = "smallgirl@smallgirl.co.kr";
$subject = "Your Passbook Pass.";
$message = "Hello,\r\nHere's your pass.";

email_pass($pass, $path, "recipient@mail.org", 
           $from_mail, $from_name, $reply_to, $subject, $message);

function email_pass($pass, $path, $mail_to, $from_mail, $from_name, $reply_to, $subject, $message) {
    $content = chunk_split(base64_encode(file_get_contents($path.$pass)));
    $uid = md5(uniqid(time()));
    $name = basename($pass);
    $header = "From: ".$from_name." <".$from_mail.">\r\n";
    $header .= "Reply-To: ".$reply_to."\r\n";
    $header .= "MIME-Version: 1.0\r\n";
    $header .= "Content-Type: multipart/mixed; boundary=\"".$uid."\"\r\n\r\n";
    $header .= "This is a multi-part message in MIME format.\r\n";
    $header .= "--".$uid."\r\n";
    $header .= "Content-type:text/plain; charset=utf-8\r\n";
    $header .= "Content-Transfer-Encoding: 7bit\r\n\r\n";
    $header .= $message."\r\n\r\n";
    $header .= "--".$uid."\r\n";
    $header .= "Content-Type: application/vnd.apple.pkpass; name=\"".$pass."\"\r\n"; // use different content types here
    $header .= "Content-Transfer-Encoding: base64\r\n";
    $header .= "Content-Disposition: attachment; filename=\"".$pass."\"\r\n\r\n";
    $header .= $content."\r\n\r\n";
    $header .= "--".$uid."--";
    if (mail($mail_to, $subject, "", $header)) {
        return true;
    } else {
        return false;
    }
}

答案 1 :(得分:0)

通过使用Mail.app,现在我可以向其他人发送一个传递给存折!