[英]Cakephp 3 email
我正在嘗試使用cakephp從我的用戶發送電子郵件,但是我希望每個用戶都使用他們自己的電子郵件,例如我的應用程序配置
'EmailTransport' => [
'default' => [
'className' => 'Smtp',
'host' => 'smtp.gmail.com',
'port' => 587,
'username' => 'formulariosdsds@gmail.com',
'password' => '***',
'tls' => true,
],
它用於App電子商店,例如accont恢復和注冊。
我希望用戶使用該應用程序以自己的電子郵件發送,就像每個用戶的傳輸器一樣。 有辦法嗎?
當然,每次用戶發送電子郵件時,您都必須創建一個配置傳輸。
$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...
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.