从iOS发送电子邮件背景

可能重复:
可能发送自动电子邮件?

这个问题已经在整个stackoverflow中的多个变化中被问到,但我不能find适用于我或那个答案我的问题。 它似乎应该是更简单,但我想要的是我的应用程序发送一个asynchronous的电子邮件在后台。 没有graphics用户界面,没有用户input,只是当模型发生什么事情时,它通过电子邮件发送给我。

提前致谢,
约旦

IOS不支持在后台邮件。 您必须实施USer互动,只有点击发送button才会发送邮件。 作为替代,您应该为此实现WebService,您可以在代码中的任何位置调用它。

需要php:

<?php //-- POST are variables from details.js $names = $_POST['names']; $address1 = $_POST['address1']; $address2 = $_POST['address2']; $crust = $_POST['crust']; $message1 = $_POST['message']; //-- clean up the javascript array $toppings = str_replace('"','',substr(substr(stripslashes($_POST['toppings']),1),0,-1)); $toppings = explode(",\n", $toppings); //-- Where the order will be sent $to = $address2; $subject = "your_Order!"; $message = $message1 ; //-- The headers will let us send HTML code as an email $headers = "From: contact@your_domain.com\r\n"; $headers .= "MIME-Version: 1.0\r\n"; $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n"; //-- if mail gets sent, return true, else return false. This gets handed off the our onload method in details.js if (mail($to,$subject,$message,$headers)) { $response = array('mail' => true); } else { $response = array('mail' => false); } echo json_encode($response); ?>