tinysms

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 17, 2020 License: MIT Imports: 5 Imported by: 0

README

tinysms

Simple free SMS client using SMTP

codecov Build Status

This is a library is perfect for small projects you are only sending a small amount of SMS to a single phone or a few you know of. Unfortunately, you need to know the user's carrier to send SMS. If you don't want to have to ask your users that. Then this project is not for you. I recommend using Twilio for this if you plan on high volumn SMS messages.

Requirements

You are required to have an SMTP server to send SMS. Google provides this for free including few other major email providers. You will need to look up or ask your provider to give you SMTP access to send messages. This library currently only supports major US wireless carriers. If you would like to add one. Please make a PR request or open an issue!

Install

go get github.com/ajm113/go-tinysms

Usuage

import "github.com/ajm113/go-tinysms"

func main() {
	c := tinysms.NewClient(&tinysms.Options{
		// SMTP Server and login settings.
		Addr:        "smtp.gmail.com:587",
		Username:    "tester@gmail.com",
		Password:    "testing",

		// How you want the from address to show on text messages.
		FromAddress: "andrew@test.com",
	})

	// Send a text message to a phone using AT&T.
	err := c.Send("5555555555", "AT&T", "tinysms Golang library is 1337!")
}

This project wants help!

Few things you can help improve the project!

  • Better carrier support of international carriers.
  • Improved documentation.
  • Better code coverage and unit tests.

License

MIT

Authors

  • Andrew McRobb

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Carriers = map[string]string{
	"alltel":        "message.alltel.com",
	"cricket":       "sms.mycricket.com",
	"at&t":          "txt.att.net",
	"bell-atlantic": "message.bam.com",
	"comcast":       "comcastpcs.textmsg.com",
	"boost":         "myboostmobile.com",
	"sprint":        "messaging.sprintpcs.com",
	"t-mobile":      "tmomail.net",
	"verizon":       "vtext.com",
	"virgin":        "vmobl.net",
	"qwest":         "qwestmp.com",
	"nextel":        "messaging.nextel.com",
}

Carriers List of carriers and their email domains.

Functions

This section is empty.

Types

type Options

type Options struct {
	// Addr we are connecting to. e.g: "smtp.gmail.com:587"
	Addr string

	// Username Sometimes email address or username used to login
	Username string
	Password string

	// FromAddress Use custom from address if service supports it. Sometimes they will ignore this.
	FromAddress string
}

Options SMTP Connection strings.

type SMSClient

type SMSClient struct {
	Options *Options
	// contains filtered or unexported fields
}

SMSClient Client object used to send SMS messages.

func NewClient

func NewClient(options *Options) (c *SMSClient)

NewClient Creates new client instant to send SMS.

func (*SMSClient) Send

func (c *SMSClient) Send(number, carrier, message string) (err error)

Send Sends SMS message to target number supplied with message string.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL