-
Notifications
You must be signed in to change notification settings - Fork 0
/
sms_telcode.go
executable file
·130 lines (123 loc) · 4.91 KB
/
sms_telcode.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
package campid
import (
"context"
"fmt"
"net/smtp"
"strings"
"github.com/influx6/npkg/nerror"
"github.com/influx6/npkg/ntrace"
openTracing "github.com/opentracing/opentracing-go"
)
var TelCoCarriers = map[string]string{
"aliant-canada": "@chat.wirefree.ca",
"alltel": "@message.alltel.com",
"ameritech": "@paging.acswireless.com",
"at&t": "@txt.att.net",
"beeline-ua": "@sms.beeline.ua",
"bell-atlantic": "@message.bam.com",
"bellmobility-canada": "@txt.bell.ca",
"bellsouthmobility": "@blsdcs.net",
"blueskyfrog": "@blueskyfrog.com",
"boost": "@myboostmobile.com",
"bpl-mobile": "@bplmobile.com",
"cellularsouth": "@csouth1.com",
"claro-brazil": "@clarotorpedo.com.br",
"claro-nicaragua": "@ideasclaro,-ca.com",
"comcast": "@comcastpcs.textmsg.com",
"cricket": "@sms.mycricket.com",
"du-arab-emirates": "@email2sms.ae",
"e-plus-germany": "@smsmail.eplus.de",
"etisalat-arab-emirates": "@email2sms.ae",
"fido-canada": "@fido.ca",
"kajeet": "@mobile.kajeet.net",
"koodoo": "@msg.koodomobile.com",
"manitobatelecom-canada": "@text.mtsmobility.com",
"metropcs": "@mymetropcs.com",
"mobinil-egypt": "@mobinil.net",
"mobistar-belgium": "@mobistar.be",
"mobitel": "@sms.mobitel.lk",
"movistar-spain": "@correo.movistar.net",
"nextel": "@messaging.nextel.com",
"northerntel-canada": "@txt.northerntelmobility.com",
"o2-germany": "@o2online.de",
"o2-uk": "@mmail.co.uk",
"orange-mumbai": "@orangemail.co.in",
"orange-netherlands": "@sms.orange.nl",
"orange-uk": "@orange.net",
"powertel": "@ptel.net",
"pscwireless": "@sms.pscel.com",
"qwest": "@qwestmp.com",
"rogers-canada": "@pcs.rogers.ca",
"rogers-wireless": "@pcs.rogers.com",
"sasktel-canada": "@sms.sasktel.ca",
"sfr-france": "@sfr.fr",
"southernlink": "@page.southernlinc.com",
"sprint": "@messaging.sprintpcs.com",
"suncom": "@tms.suncom.com",
"t-mobile": "@tmomail.net",
"t-mobile-austria": "@sms.t,-mobile.at",
"t-mobile-germany": "@gin.nl",
"t-mobile-uk": "@t,-mobile.uk.net",
"telebec-canada": "@txt.telebecmobilite.com",
"telefonica-spain": "@movistar.net",
"telus-canada": "@msg.telus.com",
"telus-mobility": "@msg.telus.com",
"tracfone": "@mmst5.tracfone.com",
"uscellular": "@email.uscc.net",
"verizon": "@vtext.com",
"virgin": "@vmobl.net",
"virgin-canada": "@vmobile.ca",
"vodafone-egypt": "@vodafone.com.eg",
"vodafone-germany": "@vodafone,-sms.de",
"vodafone-italy": "@sms.vodafone.it",
"vodafone-jp-chuugoku": "@n.vodafone.ne.jp",
"vodafone-jp-hokkaido": "@d.vodafone.ne.jp",
"vodafone-jp-hokuriko": "@r.vodafone.ne.jp",
"vodafone-jp-kansai": "@k.vodafone.ne.jp",
"vodafone-jp-kanto": "@k.vodafone.ne.jp",
"vodafone-jp-koushin": "@k.vodafone.ne.jp",
"vodafone-jp-kyuushu": "@q.vodafone.ne.jp",
"vodafone-jp-niigata": "@h.vodafone.ne.jp",
"vodafone-jp-okinawa": "@q.vodafone.ne.jp",
"vodafone-jp-osaka": "@k.vodafone.ne.jp",
"vodafone-jp-shikoku": "@s.vodafone.ne.jp",
"vodafone-jp-tokyo": "@k.vodafone.ne.jp",
"vodafone-jp-touhoku": "@h.vodafone.ne.jp",
"vodafone-jp-toukai": "@h.vodafone.ne.jp",
"vodafone-spain": "@vodafone.es",
"vodafone-uk": "@sms.vodafone.net",
}
func NumberToCarrierEmail(number string, carrier string) (string, error) {
var carrierHost, hasHost = TelCoCarriers[strings.ToLower(carrier)]
if !hasHost {
return "", nerror.New("%q carrier not found", carrier)
}
return fmt.Sprintf("%s%s", number, carrierHost), nil
}
type EmailSMS struct {
Port int
User string
Password string
Carrier string
Host string
}
// Deliver sends giving message to target number using target telco carrier
// email delivery mechanism.
//
// fromAddr: is your email address
// number: the sets of numbers with carrier to send desired message (e.g 51620726@sms.vodafone.net.
// message: the simple text message to be sent.
//
func (es *EmailSMS) Deliver(ctx context.Context, fromAddr string, message []byte, numberWithCarrier ...string) error {
var span openTracing.Span
if ctx, span = ntrace.NewMethodSpanFromContext(ctx); span != nil {
defer span.Finish()
}
var hostAddr = fmt.Sprintf("%s:%d", es.Host, es.Port)
var smtpAuth = smtp.PlainAuth("", es.User, es.Password, es.Host)
var sendErr = smtp.SendMail(hostAddr, smtpAuth, fromAddr, numberWithCarrier, message)
if sendErr != nil {
return nerror.WrapOnly(sendErr)
}
return nil
}