2017-03-08 19 views
0

私は私のユーザーからの電子メールを送信するためにCakePHPを使用しようとしているが、私は、各ユーザーが、彼らはそれがアプリケーションのために使われているcakephpの3電子メール

'EmailTransport' => [ 
'default' => [ 
    'className' => 'Smtp', 
    'host' => 'smtp.gmail.com', 
    'port' => 587, 
    'username' => '[email protected]', 
    'password' => '***', 
    'tls' => true, 
], 

例 私のアプリの設定のための電子メールを所有して使用したいです電子メールのように、回復と登録を歓迎します。

私はユーザーに、ユーザーごとにトランスポータのようなアプリを使って電子メールを送信してもらいたいと思います。それを行う方法はありますか?

答えて

2

確かに、ユーザーがメールを送信するたびに構成転送を作成する必要があります。

$transport = $user_data_email_config; 

// first you drop to prevent to add a configuration pre existing and generate an error 
Email::dropTransport($transport->name); 

// now you create a custom configuration 
Email::configTransport($transport->name, [ 
    'className' => $transport->class_name, 
    'host' => $transport->host, 
    'port' => $transport->port, 
    'timeout' => 30, 
    'username' => $transport->username, 
    'password' => $transport->password, 
    'client' => $transport->client, 
    'tls' => $transport->tls 
]); 

$Email = new Email(); 
// for use the custom configuration, set the transport providing the transport name when you configure the email. 
$Email->transport($transport->name); 
// the rest of email configuration... 
+0

ありがとうございます、それは動作します –

関連する問題