gpt4 book ai didi

pubnub - 我们可以通过电子邮件接收 pubnub 通知吗?

转载 作者:行者123 更新时间:2023-12-01 00:58:56 26 4
gpt4 key购买 nike

我们正在使用 NodeJS 发布消息。订阅者是否可以通过电子邮件接收消息?

最佳答案

目前,PubNub 支持原生的 PubNub、GCM 和 APNS 消息端点。更多信息在这里:http://www.pubnub.com/how-it-works/mobile/

如果您想将 PubNub 本地消息转发到电子邮件 (SMTP),只需获取消息正文,根据需要对其进行解析,然后发送即可。

例如,Ruby 中的一些粗略伪代码可能如下所示:

require 'net/smtp'
require 'pubnub'

def SMTPForward(message_text)

# build the headers

email = "From: Your Name <your@mail.address>
To: Destination Address <someone@example.com>
Subject: test message
Date: Sat, 23 Jun 2001 16:26:43 +0900
Message-Id: <unique.message.id.string@example.com>

" + message_text # add the PN message text to the email body

Net::SMTP.start('your.smtp.server', 25) do |smtp| # Send it!
smtp.send_message email,
'your@mail.address',
'his_address@example.com'
end

@my_callback = lambda { |envelope| SMTPForward(envelope.msg) } # Fwd to email

pubnub.subscribe( # Subscribe on channel hello_world, fwd messages to my_callback
:channel => :hello_world,
:callback => @my_callback
)

格瑞米

关于pubnub - 我们可以通过电子邮件接收 pubnub 通知吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25225300/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com