从 iOS 在后台发送电子邮件 [英] Send Email in Background from iOS

查看:32
本文介绍了从 iOS 在后台发送电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

在整个 stackoverflow 中,这个问题以多种变体被问到,但我找不到一个适合我或回答我的问题的问题.看起来它应该更简单,但我想要的只是让我的应用程序在后台发送异步电子邮件.没有 GUI,没有用户输入,只是当模型中发生某些事情时,它会通过电子邮件通知我.

This question has been asked in multiple variations throughout stackoverflow, but I can't quite find one that applies to me or that answers my question. It seems like it should be more simple but all I want is for my app to send an asynchronous email in the background. No GUI, no user input, just that when something happens in the model it emails me about it.

提前致谢,
乔丹

Thanks in advance,
Jordan

推荐答案

IOS 不支持后台发送邮件.您必须实现用户交互 &只有点击发送按钮才会发送邮件.作为替代方案,您应该为此 & 实现 WebService.您可以在代码中的任何位置调用它.

IOS doesn't support to mail in background. You must implement the USer interaction & only clicking over send button will be sending the mail. As an alternate you should implement the WebService for this & you can call it anywhere in you code.

需要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(",
", $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
";
$headers .= "MIME-Version: 1.0
";
$headers .= "Content-Type: text/html; charset=ISO-8859-1
";

//-- 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);
?>

这篇关于从 iOS 在后台发送电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆