diff --git a/src/.env.example b/src/.env.example index 1dfffca1..178ba546 100644 --- a/src/.env.example +++ b/src/.env.example @@ -1,54 +1,56 @@ APP_NAME=Kolab APP_ENV=local APP_KEY= APP_DEBUG=true APP_URL=http://127.0.0.1:8000 LOG_CHANNEL=stack DB_CONNECTION=sqlite BROADCAST_DRIVER=log CACHE_DRIVER=file QUEUE_CONNECTION=sync SESSION_DRIVER=file SESSION_LIFETIME=120 LDAP_ADMIN_BIND_DN="cn=Directory Manager" LDAP_ADMIN_BIND_PW=Welcome2KolabSystems LDAP_DOMAIN_BASE_DN=ou=Domains,dc=mgmt,dc=com LDAP_HOSTED_BASE_DN=dc=hosted,dc=com LDAP_HOSTED_SEARCH_BIND_DN="uid=hosted-kolab-service,ou=Special Users,dc=mgmt,dc=com" LDAP_HOSTED_SEARCH_BIND_PW=Welcome2KolabSystems LDAP_HOSTNAME=127.0.0.1 LDAP_SEARCH_BIND_DN="uid=kolab-service,ou=Special Users,dc=mgmt,dc=com" LDAP_SEARCH_BIND_PW=Welcome2KolabSystems REDIS_HOST=127.0.0.1 REDIS_PASSWORD=null REDIS_PORT=6379 SWOOLE_HTTP_HOST=127.0.0.1 SWOOLE_HTTP_PORT=8000 MAIL_DRIVER=smtp MAIL_HOST=smtp.mailtrap.io MAIL_PORT=2525 MAIL_USERNAME=null MAIL_PASSWORD=null MAIL_ENCRYPTION=null +MAIL_FROM_ADDRESS="noreply@example.com" +Mail_FROM_NAME="Example.com" AWS_ACCESS_KEY_ID= AWS_SECRET_ACCESS_KEY= AWS_DEFAULT_REGION=us-east-1 AWS_BUCKET= PUSHER_APP_ID= PUSHER_APP_KEY= PUSHER_APP_SECRET= PUSHER_APP_CLUSTER=mt1 MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}" MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}" JWT_SECRET= diff --git a/src/app/Jobs/SignupVerificationEmail.php b/src/app/Jobs/SignupVerificationEmail.php index b18fe3b5..63e8c958 100644 --- a/src/app/Jobs/SignupVerificationEmail.php +++ b/src/app/Jobs/SignupVerificationEmail.php @@ -1,56 +1,58 @@ code = $code; } /** * Determine the time at which the job should timeout. * * @return \DateTime */ public function retryUntil() { // FIXME: I think it does not make sense to continue trying after 1 hour return now()->addHours(1); } /** * Execute the job. * * @return void */ public function handle() { - // TODO + Mail::to($this->code->data['email'])->send(new SignupVerification($this->code)); } } diff --git a/src/app/Mail/SignupVerification.php b/src/app/Mail/SignupVerification.php new file mode 100644 index 00000000..650a112a --- /dev/null +++ b/src/app/Mail/SignupVerification.php @@ -0,0 +1,49 @@ +code = $code; + } + + /** + * Build the message. + * + * @return $this + */ + public function build() + { + $this->view('emails.signup_code') + ->subject(__('mail.signupcode-subject', ['site' => config('app.name')])) + ->with([ + 'username' => $this->code->data['name'], + 'code' => $this->code->code, + 'short_code' => $this->code->short_code, + 'url_code' => $this->code->short_code . '-' . $this->code->code, + ]); + + return $this; + } +} diff --git a/src/config/mail.php b/src/config/mail.php index 6f8469f8..784847ad 100644 --- a/src/config/mail.php +++ b/src/config/mail.php @@ -1,136 +1,136 @@ env('MAIL_DRIVER', 'smtp'), /* |-------------------------------------------------------------------------- | SMTP Host Address |-------------------------------------------------------------------------- | | Here you may provide the host address of the SMTP server used by your | applications. A default option is provided that is compatible with | the Mailgun mail service which will provide reliable deliveries. | */ 'host' => env('MAIL_HOST', 'smtp.mailgun.org'), /* |-------------------------------------------------------------------------- | SMTP Host Port |-------------------------------------------------------------------------- | | This is the SMTP port used by your application to deliver e-mails to | users of the application. Like the host we have set this value to | stay compatible with the Mailgun e-mail application by default. | */ 'port' => env('MAIL_PORT', 587), /* |-------------------------------------------------------------------------- | Global "From" Address |-------------------------------------------------------------------------- | | You may wish for all e-mails sent by your application to be sent from | the same address. Here, you may specify a name and address that is | used globally for all e-mails that are sent by your application. | */ 'from' => [ 'address' => env('MAIL_FROM_ADDRESS', 'hello@example.com'), 'name' => env('MAIL_FROM_NAME', 'Example'), ], /* |-------------------------------------------------------------------------- | E-Mail Encryption Protocol |-------------------------------------------------------------------------- | | Here you may specify the encryption protocol that should be used when | the application send e-mail messages. A sensible default using the | transport layer security protocol should provide great security. | */ 'encryption' => env('MAIL_ENCRYPTION', 'tls'), /* |-------------------------------------------------------------------------- | SMTP Server Username |-------------------------------------------------------------------------- | | If your SMTP server requires a username for authentication, you should | set it here. This will get used to authenticate with your server on | connection. You may also set the "password" value below this one. | */ 'username' => env('MAIL_USERNAME'), 'password' => env('MAIL_PASSWORD'), /* |-------------------------------------------------------------------------- | Sendmail System Path |-------------------------------------------------------------------------- | | When using the "sendmail" driver to send e-mails, we will need to know | the path to where Sendmail lives on this server. A default path has | been provided here, which will work well on most of your systems. | */ 'sendmail' => '/usr/sbin/sendmail -bs', /* |-------------------------------------------------------------------------- | Markdown Mail Settings |-------------------------------------------------------------------------- | | If you are using Markdown based email rendering, you may configure your | theme and component paths here, allowing you to customize the design | of the emails. Or, you may simply stick with the Laravel defaults! | */ 'markdown' => [ 'theme' => 'default', 'paths' => [ - resource_path('views/vendor/mail'), + resource_path('views/emails'), ], ], /* |-------------------------------------------------------------------------- | Log Channel |-------------------------------------------------------------------------- | | If you are using the "log" driver, you may specify the logging channel | if you prefer to keep mail messages separate from other log entries | for simpler reading. Otherwise, the default channel will be used. | */ 'log_channel' => env('MAIL_LOG_CHANNEL'), ]; diff --git a/src/resources/lang/en/mail.php b/src/resources/lang/en/mail.php new file mode 100644 index 00000000..727f8ec2 --- /dev/null +++ b/src/resources/lang/en/mail.php @@ -0,0 +1,20 @@ + 'Dear :name,', + 'footer' => "Best regards,\nYour :sitename Team", + + 'signupcode-subject' => ':sitename Registration', + 'signupcode-body' => "This is your verification code for the :sitename registration process: :code.\n" + . "You can also click the link below to continue the registration process:", + +]; diff --git a/src/resources/views/emails/signup_code.blade.php b/src/resources/views/emails/signup_code.blade.php new file mode 100644 index 00000000..f2bf15dd --- /dev/null +++ b/src/resources/views/emails/signup_code.blade.php @@ -0,0 +1,15 @@ + + + + + + +

{{ __('mail.header', ['name' => $username]) }}

+ +

{{ __('mail.signupcode-body', ['code' => $short_code, 'sitename' => config('app.name')]) }}

+ +

{{ config('app.url') }}/signup/{{ $url_code }}

+ +

{{ __('mail.footer', ['sitename' => config('app.name'), 'appurl' => config('app.url')]) }}

+ +