php 发送短信_使用PHP发送短信

php 发送短信

Text Message

Kids these days, I tell ya.  All they care about is the technology.  The video games.  The bottled water.  Oh, and the texting, always the texting.  Back in my day, all we had was...OK, I had all of these things too.  But I still don't get the volume of texts that I hear my younger female cousins send.  Thousands and thousands of them each month.  WTF are all of these texts for?  Here's a thought:

这些天,孩子们,我告诉你。 他们只关心技术。 电子游戏。 瓶装水。 哦,还有短信,总是短信。 回想过去,我们所拥有的只是……好,我也拥有所有这些东西。 但是我仍然听不到我年轻的表弟寄来的文字。 每个月成千上万。 WTF都是这些文本吗? 这是一个想法:

omg did you hear?

天哪,你听到了吗?

no wut

没关系

omg i can't believe you didn't hear

天哪,我简直不敢相信你没有听到

lol tell me!

大声笑告诉我!

jenny and mark were holding hands

珍妮和马克手牵着手

omfg does john no?

omfg约翰不吗?

ok i made it up, ur so lame

好吧,我做了,你这么la脚

Riveting.  Jokes aside, text messaging can be an extremely useful way to get out of calling that person you hate calling  communicate quickly and efficiently.  Many websites are now offering text message notifications instead of email notifications, which can be nice in the case of time-sensitive information.  After a bit of research, I found out how easy it was so send text messages using PHP, so that I can integrate text messaging into my apps!  Let me show you how!

铆。 除了笑话,短信是一种非常有用的方式 ,可以避免您讨厌打电话的那个人 快速有效地进行交流。 现在,许多网站都提供文本消息通知而不是电子邮件通知,这对于时间敏感的信息可能会很好。 经过一些研究,我发现使用PHP发送文本消息非常容易,这样我就可以将文本消息集成到我的应用程序中了! 让我告诉你怎么做!

方法论 (The Methodology)

Unbeknownst to me, sending text messages can be as easy as sendmail, because you can send your text to an email address and it will be delivered.  There are two pieces of information you must know:  the phone number and the carrier's text message email domain.  Needing to know the recipient's carrier is not ideal, but necessary.  Luckily Kevin Jensen has compiled a list of carriers and domains:

对我来说不为人所知,发送短信就像sendmail一样容易,因为您可以将文本发送到电子邮件地址,然后它将被发送。 您必须知道两点信息:电话号码和运营商的短信电子邮件域。 需要了解接收者的携带者不是理想的,而是必要的。 幸运的是,凯文·詹森(Kevin Jensen) 整理了一份运营商和域名列表

Phone companies have internal lookups for phone carriers but developers like you and I don't get access to them, so knowing the carrier is  a must.  To send a text message, you email {phoneNumber}@{carrierDomain}.

电话公司对电话运营商进行内部查询,但是像您和我这样的开发人员无法访问它们,因此了解运营商是必须的。 要发送短信,请发送电子邮件至{phoneNumber}@{carrierDomain}

PHP (The PHP)

PHP's provided method for sending emails is the mail function.  Its usage is quite simple:

PHP提供的用于发送电子邮件的方法是mail函数 。 它的用法很简单:


bool mail ( string $to , string $subject , string $message [, string $additional_headers [, string $additional_parameters ]] )


Using the mail function and the text message email format, sending a text message is as easy as:

使用邮件功能和短信电子邮件格式,发送短信很容易:


// Call Jenny
mail("5558675309@txt.att.net", "", "Your packaged has arrived!", "From: David Walsh <david@davidwalsh.name>\r\n");


Note that no subject line is provided, and more importantly, a FROM header is within the last parameter so that the recipient knows where the text message has been sent from.

请注意,没有提供任何主题行,更重要的是,FROM头位于最后一个参数内,以便收件人知道文本消息的发送来源。

Who knew it was that easy?  I always assumed text messaging had its own protocol and all that magic.  Apparently not!  Spend a few minutes playing around with text messaging yourself;  it's one of those things that's both neat to do and useful!

谁知道这很容易? 我一直以为短信具有自己的协议和所有魔力。 显然不是! 花几分钟时间自己玩短信。 这是既整洁又有用的事情之一!

翻译自: https://davidwalsh.name/send-text-message

php 发送短信

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值