@@ -331,15 +331,7 @@ protected function updateUser($user)
331331 protected function emailVerificationLink (AuthenticatableContract $ user , $ subject , $ from = null , $ name = null )
332332 {
333333 return $ this ->mailer ->send ($ this ->emailView , compact ('user ' ), function ($ m ) use ($ user , $ subject , $ from , $ name ) {
334- if (! empty ($ from )) {
335- $ m ->from ($ from , $ name );
336- }
337-
338- $ m ->to ($ user ->email );
339-
340- $ m ->subject (is_null ($ subject ) ? trans ('laravel-user-verification::user-verification.verification_email_subject ' ) : $ subject );
341-
342- event (new VerificationEmailSent ($ user ));
334+ $ m = $ this ->createVerificationEmail ($ m , $ user , $ subject , $ from , $ name );
343335 });
344336 }
345337
@@ -355,15 +347,7 @@ protected function emailVerificationLink(AuthenticatableContract $user, $subject
355347 protected function emailQueueVerificationLink (AuthenticatableContract $ user , $ subject , $ from = null , $ name = null )
356348 {
357349 return $ this ->mailer ->queue ($ this ->emailView , compact ('user ' ), function ($ m ) use ($ user , $ subject , $ from , $ name ) {
358- if (! empty ($ from )) {
359- $ m ->from ($ from , $ name );
360- }
361-
362- $ m ->to ($ user ->email );
363-
364- $ m ->subject (is_null ($ subject ) ? trans ('laravel-user-verification::user-verification.verification_email_subject ' ) : $ subject );
365-
366- event (new VerificationEmailSent ($ user ));
350+ $ m = $ this ->createVerificationEmail ($ m , $ user , $ subject , $ from , $ name );
367351 });
368352 }
369353
@@ -380,15 +364,7 @@ protected function emailQueueVerificationLink(AuthenticatableContract $user, $su
380364 protected function emailQueueOnVerificationLink ($ queue , AuthenticatableContract $ user , $ subject , $ from = null , $ name = null )
381365 {
382366 return $ this ->mailer ->queueOn ($ queue , $ this ->emailView , compact ('user ' ), function ($ m ) use ($ user , $ subject , $ from , $ name ) {
383- if (! empty ($ from )) {
384- $ m ->from ($ from , $ name );
385- }
386-
387- $ m ->to ($ user ->email );
388-
389- $ m ->subject (is_null ($ subject ) ? trans ('laravel-user-verification::user-verification.verification_email_subject ' ) : $ subject );
390-
391- event (new VerificationEmailSent ($ user ));
367+ $ m = $ this ->createVerificationEmail ($ m , $ user , $ subject , $ from , $ name );
392368 });
393369 }
394370
@@ -405,15 +381,7 @@ protected function emailQueueOnVerificationLink($queue, AuthenticatableContract
405381 protected function emailLaterVerificationLink ($ seconds , AuthenticatableContract $ user , $ subject , $ from = null , $ name = null )
406382 {
407383 return $ this ->mailer ->later ($ seconds , $ this ->emailView , compact ('user ' ), function ($ m ) use ($ user , $ subject , $ from , $ name ) {
408- if (! empty ($ from )) {
409- $ m ->from ($ from , $ name );
410- }
411-
412- $ m ->to ($ user ->email );
413-
414- $ m ->subject (is_null ($ subject ) ? trans ('laravel-user-verification::user-verification.verification_email_subject ' ) : $ subject );
415-
416- event (new VerificationEmailSent ($ user ));
384+ $ m = $ this ->createVerificationEmail ($ m , $ user , $ subject , $ from , $ name );
417385 });
418386 }
419387
@@ -430,16 +398,33 @@ protected function emailLaterVerificationLink($seconds, AuthenticatableContract
430398 protected function emailLaterOnVerificationLink ($ queue , $ seconds , AuthenticatableContract $ user , $ subject , $ from = null , $ name = null )
431399 {
432400 return $ this ->mailer ->laterOn ($ queue , $ seconds , $ this ->emailView , compact ('user ' ), function ($ m ) use ($ user , $ subject , $ from , $ name ) {
433- if (! empty ( $ from)) {
434- $ m -> from ( $ from , $ name );
435- }
401+ $ m = $ this -> createVerificationEmail ( $ m , $ user , $ subject , $ from, $ name );
402+ } );
403+ }
436404
437- $ m ->to ($ user ->email );
405+ /**
406+ * Creates and format the e-mail to be sent.
407+ *
408+ * @param string $mail
409+ * @param \Illuminate\Contracts\Auth\Authenticatable $user
410+ * @param string $subject
411+ * @param string $from
412+ * @param string $name
413+ * @return mixed
414+ */
415+ protected function createVerificationEmail ($ mail , $ user , $ subject , $ from , $ name )
416+ {
417+ if (! empty ($ from )) {
418+ $ mail ->from ($ from , $ name );
419+ }
438420
439- $ m -> subject ( is_null ( $ subject ) ? trans ( ' laravel- user-verification::user-verification.verification_email_subject ' ) : $ subject );
421+ $ mail -> to ( $ user -> email );
440422
441- event (new VerificationEmailSent ($ user ));
442- });
423+ $ mail ->subject (is_null ($ subject ) ? trans ('laravel-user-verification::user-verification.verification_email_subject ' ) : $ subject );
424+
425+ event (new VerificationEmailSent ($ user ));
426+
427+ return $ mail ;
443428 }
444429
445430 /**
0 commit comments