Я разрабатываю чат-бота с laravel, botman studio и telegram API, мне нужно отправлять электронные письма на gmail.
Когда я делаю тесты с ботаном / тинкером, он отправляет электронное письмо
Но когда я делаю тесты с бот-телеграммой, это не работает.
Здесь я оставляю часть кода, который я использую, я не знаю, так ли это, потому что класс Conversation в Botman Studioне принимает класс Mailable, вы можете мне помочь?
Вот мой код:
<? php
namespace App \ Conversations;
use Illuminate \ Foundation \ Inspiring;
use BotMan \ BotMan \ Messages \ Incoming \ Answer;
use BotMan \ BotMan \ Messages \ Outgoing \ Question;
use BotMan \ BotMan \ Messages \ Outgoing \ Actions \ Button;
use BotMan \ BotMan \ Messages \ Conversations \ Conversation;
use App \ Products;
use App \ config \ botman \ config;
use Illuminate \ Support \ Facades \ Mail;
use Illuminate \ Support \ Facades \ View;
class testsbot extends Conversation
{
/ **
* Start the conversation.
*
* @return mixed
* /
public function run ()
{
$ this-> askEmail ();
}
private function askEmail () {
$ this-> ask ('Enter the email', function (Answer $ answer) {
// Save result
$ this-> valueEmail = $ answer-> getText ();
$ this-> configLenguage ();
});
}
public function configLenguage ()
{
$ object = \ App \ Products :: select ('id', 'code', 'stocks') -> where ('status', '=', 'ACTIVE') -> get ();
$ email = $ this-> valueEmail;
Mail :: to ($ email) -> send (new Mailes ($ object));
$ this-> say ('works');
}
}
?>
<?php
namespace App\Mail;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Queue\ShouldQueue;
class DemoEmail extends Mailable
{
use Queueable, SerializesModels;
/**
* The demo object instance.
*
* @var Demo
*/
public $demo;
/**
* Create a new message instance.
*
* @return void
*/
public function __construct($demo)
{
$this->demo = $demo;
}
/**
* Build the message.
*
* @return $this
*/
public function build()
{
return $this->from('andi.am770@gmail.com')
->view('mails.demo')
->text('mails.demo_plain')
->with(
[
'testVarOne' => '1',
'testVarTwo' => '2',
]);
}
}