@@ -51,6 +51,8 @@ public function send($notifiable, Notification $notification)
51
51
52
52
try {
53
53
$ message = $ notification ->toTwilio ($ notifiable );
54
+ $ params = [];
55
+ $ from = null ;
54
56
55
57
if (is_string ($ message )) {
56
58
$ message = new TwilioSmsMessage ($ message );
@@ -60,11 +62,23 @@ public function send($notifiable, Notification $notification)
60
62
throw CouldNotSendNotification::invalidMessageObject ($ message );
61
63
}
62
64
63
- if (! $ from = $ message ->from ?: config ('services.twilio.from ' )) {
65
+ if (method_exists ($ notifiable , 'canReceiveAlphanumericSender ' ) &&
66
+ $ notifiable ->canReceiveAlphanumericSender () &&
67
+ $ sender = config ('services.twilio.alphanumeric_sender ' )) {
68
+ $ from = $ sender ;
69
+ } else {
70
+ $ from = $ message ->from ?: config ('services.twilio.from ' );
71
+ }
72
+
73
+ if (! $ from ) {
64
74
throw CouldNotSendNotification::missingFrom ();
65
75
}
66
76
67
- return $ this ->sendMessage ($ message , $ from , $ to );
77
+ if ($ serviceSid = config ('services.twilio.sms_service_sid ' )) {
78
+ $ params ['MessagingServiceSid ' ] = $ serviceSid ;
79
+ }
80
+
81
+ return $ this ->sendMessage ($ message , $ from , $ to , $ params );
68
82
} catch (Exception $ exception ) {
69
83
$ this ->events ->fire (
70
84
new NotificationFailed ($ notifiable , $ notification , 'twilio ' , ['message ' => $ exception ->getMessage ()])
@@ -80,13 +94,15 @@ public function send($notifiable, Notification $notification)
80
94
*
81
95
* @throws \NotificationChannels\Twilio\Exceptions\CouldNotSendNotification
82
96
*/
83
- protected function sendMessage ($ message , $ from , $ to )
97
+ protected function sendMessage ($ message , $ from , $ to, $ params = [] )
84
98
{
85
99
if ($ message instanceof TwilioSmsMessage) {
86
100
return $ this ->twilio ->account ->messages ->sendMessage (
87
101
$ from ,
88
102
$ to ,
89
- trim ($ message ->content )
103
+ trim ($ message ->content ),
104
+ null ,
105
+ $ params
90
106
);
91
107
}
92
108
0 commit comments