-1

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

4

2 回答 2

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;
    }
}
于 2013-03-28T07:43:30.360 回答
0

通过使用Mail.app,现在我可以将通行证发送给其他人以添加到存折!

于 2013-04-09T03:17:30.537 回答