脚本宝典收集整理的这篇文章主要介绍了如何调用php文件发送邮件? ,Android,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
<?PHP $name = $_POST['name']; $to = $_POST['to']; $From = $_POST['from']; $subject = $_POST['subject']; $message = "From: ".$name."\r\n"; $message .= $_POST['message']; $headers = "From:" . $from; mail($to,$subject,$message,$headers); ?>
我想在点击发送按钮后发送邮件到静态邮件,例如:mymail@mail.COM.
如何通过调用上面的PHP文件发送邮件.
我听说过调用上面的PHP文件的post方法
但是对它没有任何想法.
请帮忙 !
public static void sendData(String name,String to,String from,String subject,String message) { String content = ""; try { /* Sends data through a HTTP POST request */ DefaultHttpClient httpClient = new DefaultHttpClient(); HttpPost httpPost = new HttpPost("http://your.websITe.com"); List <NameValuePair> params = new ArrayList <NameValuePair>(); params.add(new BasicNameValuePair("name",name)); params.add(new BasicNameValuePair("to",to)); params.add(new BasicNameValuePair("from",from)); params.add(new BasicNameValuePair("subject",subject)); params.add(new BasicNameValuePair("message",message)); httpPost.setEntity(new UrlencodedFormEntity(params,HTTP.UTF_8)); /* Reads the server response */ HttPResponse response = httpClient.execute(httpPost); InputStream in = response.getEntity().getContent(); StringBuffer sb = new StringBuffer(); int chr; while ((chr = in.read()) != -1) { sb.apPEnd((char) chr); } content = sb.toString(); in.close(); /* If there is a response,display it */ if (!content.equals("")) { LOG.i("HTTP Response",content); } } catch (Exception e) { e.printStackTrace(); } }
以上是脚本宝典为你收集整理的如何调用php文件发送邮件? ,Android全部内容,希望文章能够帮你解决如何调用php文件发送邮件? ,Android所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。