使用PHP动态发送文本消息的问题

时间:2011-05-01 21:24:39

标签: php sms

我正在尝试使用PHP脚本动态发送短信。 PHP代码:

$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=utf-8' . "\r\n";

$textbody=<<<_MESSAGE_
Some text
_MESSAGE_;

mail('myphonenumber@SMSgateway','subject',$textbody,$headers);

我确实收到了短信,但它是“照片信息”,而是多媒体而非文字,我无法打开信息。我尝试过使用编码和 $ textbody =“this text”; 而不是* MESSAGE *。

a)如何发送普通短信(而不是多媒体)?

b)为什么我不能打开它?

c)人们有没有办法回复我发送的文字?当我从hotmail发送自己的文本时,我能够回复,我在收件箱中得到了答案。当我试图放置$header.= 'From: me <me@somedomain.com>' . "\r\n";时,电子邮件不会发送

  

(原因:553抱歉,你的邮件是   行政否认。 (#5.7.1))

谢谢!

1 个答案:

答案 0 :(得分:0)

$sendTo = "test@test.com";
$subject = trim($_POST['subj']);
$headers = "From: ".$_POST['name']."<" . trim($_POST["email"]) .">\r\n";
$headers .= "Reply-To: " . trim($_POST["email"]) . "\r\n";
$headers .= "Return-path: " . trim($_POST["email"]);
$headers .= "\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=utf-8\r\n";
$message = strip_tags($_POST["messg"]);

if (@mail($sendTo, $subject, $message, $headers))
{ echo "sent successfully"; }
else 
{ echo "Error ... Plz try again later" ; }

我用来发送电子邮件的代码 我之前在SMS项目上工作过,如果您对如何与Getaway建立联系有任何疑问,请随时与我联系