2017-03-08 1 views
0

내 사용자의 이메일을 보내도록 CakePHP의를 사용하기 위해 노력하고있어,하지만 난 각각의 사용자들이이 앱을 위해 사용되는CakePHP의 3 이메일

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

예를 내 응용 프로그램의 설정에 대한 이메일을 소유하고 사용합니다 e-mais는 회복과 등록을 좋아합니다.

각 사용자에 대해 전송기와 같은 앱을 사용하여 사용자가 전자 메일을 보내도록하고 싶습니다. 그것을 할 수있는 방법이 있습니까?

답변

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

고맙습니다. –