通过 PHP 发送短信/短信

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1383469/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 02:18:24  来源:igfitidea点击:

SMS/Text message sending via PHP

phpweb-applicationssms

提问by Onion

I'm interested in knowing if it would be at all feasible to be able to send text messages via PHP. The main purpose of which would be to send a single message to a group of people - 10+ - with updates regarding news and such. Preferably the solution should be free, though it is not a necessity in any way. Thanks to all in advance.

我很想知道通过 PHP 发送短信是否可行。其主要目的是向一群人发送一条消息 - 10+ - 包含有关新闻等的更新。最好的解决方案应该是免费的,尽管它在任何方面都不是必需的。提前感谢大家。

回答by Fiarr

I've done this with PHP, and it works very well. Text messages are nothing more than an email, usually with the receiver's 10 digit number @address.com. If you want to send text messages to someone with PHP, you'll need to get the proper address:

我已经用 PHP 做到了这一点,而且效果很好。短信只不过是一封电子邮件,通常带有收件人的 10 位数字@address.com。如果您想向使用 PHP 的人发送短信,您需要获取正确的地址:

Here is a Partial List

这是部分清单

You'll want to be careful with how long your messages get, since at about 55 characters (I believe) your message can be either split into multiple texts, or lost.

您需要注意消息的长度,因为大约 55 个字符(我相信)您的消息可能会被分成多个文本,或者丢失。

Sending texts via email is free.

通过电子邮件发送文本是免费的。

回答by Phill Pafford

回答by Pascal MARTIN

I'm interested in knowing if it would be at all feasible to be able to send text messages via PHP

我很想知道通过 PHP 发送短信是否可行

Of course, it is feasible ;-)
Everything can be done, in PHP ;-)

当然,这是可行的 ;-)
一切都可以在 PHP 中完成 ;-)

For more informations, you can take a look at these questions/answers, which provide some useful informations :

有关更多信息,您可以查看这些问题/答案,其中提供了一些有用的信息:

There are several providers that you can use as gateway to send SMS ; still, probably not free (SMS are not free, after all, generally speaking) -- but costs are not that big...

有几个提供商可以用作发送 SMS 的网关;仍然,可能不是免费的(毕竟,一般来说,短信不是免费的)——但成本并没有那么大......

回答by user3144832

If you have your own android phone and don't want to pay for a SMS Gateway you can set up your own one.

如果您有自己的安卓手机并且不想为短信网关付费,您可以设置自己的手机。

download SMS Gateway API(Play store) which is a free app that you can use to send and receive messages using HTTP requests. here is a PHP example from their site.

下载SMS Gateway APIPlay 商店),这是一个免费的应用程序,您可以使用它通过 HTTP 请求发送和接收消息。这是他们网站上的一个 PHP 示例。

$URL = "http://v2.smsgateway.me/API/Send/Single.php";

$postdata = http_build_query(
    array(
    'Username' => "[email protected]",
    'Password' => "password",
    'Number' => "+447791064782",
    'Message' => "Hello World!",
    )
);

$opts = array('http' => array('method'  => 'POST', 'header'  => 'Content-type: application/x-www-form-urlencoded', 'content' => $postdata));

$context  = stream_context_create($opts);

$result = file_get_contents($URL, false, $context);

回答by Ronald Conco

To be able to send text messages as in sms you will need a sms gateway, this can be setup very easily. I have created in the past an app that converts an email into an sms via php using the pear mail lib, and you can also do it the other way around where an sms is converted into an email... the only tricky part would be getting an sms gateway that provides a very friendly interface

为了能够像短信一样发送短信,您需要一个短信网关,这可以很容易地设置。我过去创建了一个应用程序,该应用程序使用 pear 邮件库通过 php 将电子邮件转换为短信,您也可以通过将短信转换为电子邮件的另一种方式来做到这一点......唯一棘手的部分是获得一个提供非常友好界面的短信网关

回答by chaos

If this is, for example, an internal reporting application, usually the easiest way to get SMSes out to people is to use their telecom service providers' email-to-SMS gateways. This requires that said service providers have them, but the majors all do. All you do is find out the email address to send to in order to SMS to each person and use mail()or some such to send an email there.

例如,如果这是一个内部报告应用程序,通常向人们发送 SMS的最简单方法是使用他们的电信服务提供商的电子邮件到 SMS 网关。这要求上述服务提供商拥有它们,但专业人士都拥有。您所做的就是找出要发送到的电子邮件地址,以便向每个人发送短信,然后使用mail()或使用此类地址在那里发送电子邮件。