When it comes to SMS marketing, your contacts have several options for opting in to receive SMS messages from you and your company. First, they can provide their mobile number to you on a form on which they indicate they want to receive messages from you. This allows you to send them longcode messages.
Your other option is to use shortcodes. With shortcodes, your potential contacts text in to your specific number to say they wish to receive your communications. When they do so, you have received consent to send messages to them from that shortcode.
You can learn more about the differences between shortcode and longcode here.