此代码在单独运行时效果很好:
<?php
$to = "abc@yahoo.com";
$subject = "Hi!";
$body = "Hi,\n\nHow are you?";
$headers = "From: mk@example.com\r\n" ."X-Mailer: php";
if (mail($to, $subject, $body, $headers))
{
echo "Message sent!";
}
else
{
echo "Message delivery failed...";
}
?>
但是从android调用时,以下代码不起作用:
<?php
$to = $_GET['mailid'];
$subject = "QUICKACCESS";
$body = $_GET['msg'];
$headers = "From: mk@example.com\r\n" ."X-Mailer: php";
if (mail($to, $subject, $body, $headers))
{
echo "Message sent!";
}
else
{
echo "Message delivery failed...";
}
?>
这两个代码都显示“Message Sent!”但只有第一个代码实际上是发送消息,其次只显示已发送的消息,而不是实际的消息。