Skip to content

Commit 83ac921

Browse files
committed
Add a custom From and Name to send an e-mail
1 parent 89f9072 commit 83ac921

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/UserVerification.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,17 +93,19 @@ protected function saveToken(AuthenticatableContract $user, $token)
9393
*
9494
* @param \Illuminate\Contracts\Auth\Authenticatable $user
9595
* @param string $subject
96+
* @param string $from
97+
* @param string $name
9698
* @return bool
9799
*
98100
* @throws \Jrean\UserVerification\Exceptions\ModelNotCompliantException
99101
*/
100-
public function send(AuthenticatableContract $user, $subject = null)
102+
public function send(AuthenticatableContract $user, $subject = null, $from = null, $name = null)
101103
{
102104
if (! $this->isCompliant($user)) {
103105
throw new ModelNotCompliantException();
104106
}
105107

106-
return (boolean) $this->emailVerificationLink($user, $subject);
108+
return (boolean) $this->emailVerificationLink($user, $subject, $from, $name);
107109
}
108110

109111
/**
@@ -216,11 +218,17 @@ protected function updateUser($user)
216218
*
217219
* @param \Illuminate\Contracts\Auth\Authenticatable $user
218220
* @param string $subject
221+
* @param string $from
222+
* @param string $name
219223
* @return mixed
220224
*/
221-
protected function emailVerificationLink(AuthenticatableContract $user, $subject)
225+
protected function emailVerificationLink(AuthenticatableContract $user, $subject, $from = null, $name = null)
222226
{
223-
return $this->mailer->send('emails.user-verification', compact('user'), function ($m) use ($user, $subject) {
227+
return $this->mailer->send('emails.user-verification', compact('user'), function ($m) use ($user, $subject, $from, $name) {
228+
if (! empty($from)) {
229+
$m->from($from, $name);
230+
}
231+
224232
$m->to($user->email);
225233

226234
$m->subject(is_null($subject) ? 'Your Account Verification Link' : $subject);

0 commit comments

Comments
 (0)