0
複数のメールIDを使用してメールを送信しようとしています。 私のSMTP電子メールの詳細:cakephpの複数のメールIDを使用してメールを送信する
$DomainEmailDetails = $this-> DomainEmailDetails->find('all');
$DomainEmailDetails = $DomainEmailDetails->toArray();
結果:
Array
(
[0] => App\Model\Entity\DomainEmailDetail Object
(
[id] => 1
[name] => email1
[user_name] => [email protected]
[user_password] => abc123
[host_name] => smtp.gmail.com
[port] => 465
[reply_email_id] => [email protected]
)
[1] => App\Model\Entity\DomainEmailDetail Object
(
[id] => 2
[name] => email2
[user_name] => [email protected]
[user_password] => xyz123
[host_name] => smtp.gmail.com
[port] => 465
[reply_email_id] => [email protected]
)
)
と電子メールの送信のコードは次のとおりです。
によって送信するすべての10のメールに第二電子メールのログイン情報を取るためにどのようにfor ($emp=0; $emp <20 ; $emp++) {
foreach ($DomainEmailDetails as $key => $DomainEmailDetails) {
$host = 'ssl://'.$DomainEmailDetails['host_name'];
$username = $DomainEmailDetails['user_name'];
$password = $DomainEmailDetails['user_password'];
$port = $DomainEmailDetails['port'];
$email_to = '[email protected]';
$senderName = 'Web';
$ReplyTo = $DomainEmailDetails['reply_email_id'];
Email::configTransport('WebMail', [
'className' => 'Smtp',
'host' => $host,
'port' => $port,
'timeout' => 30,
'username' => $username,
'password' => $password,
'client' => null,
'tls' => null,
]);
////////// SEND MAIL
$email = new Email('WebMail');
$email ->template('default','default')
->emailFormat('both')
->from([$username => $senderName])
->to($email_to)
->replyTo($ReplyTo)
->subject('Client Message');
for ($i=0; $i <10 ; $i++) {
$response = $email->send($msgsend);
}
}
}
1つのuser_name.Iは、user_name = [email protected]は、SMTPログインの詳細が2番目のuser_name = [email protected]を自動的に設定した後、一度に10個のメールを送信できるということを意味します。これを試してみてください10電子メールは、第二usename
私の答えを更新し、ここで$メール –
何ですか。申し訳ありませんが、この変数はありませんでした。 – Ish
私はあなたのコードを使用するとき私は1回目のユーザー名を取得し、2回目のユーザー名は10回 –