gpt4 book ai didi

php - cakePHP发送的电子邮件,如何在变量中设置管理员电子邮件地址?

转载 作者:可可西里 更新时间:2023-11-01 08:40:15 27 4
gpt4 key购买 nike

我写了一个注册函数,注册后我想从管理员邮件地址发送一封电子邮件。如何在变量中设置管理员电子邮件地址?

这是我的功能:

function registration() {
$this->loadModel('User');
$this->loadModel('Role');
if ($this->request->is('post')) {
$this->User->set($this->request->data);
if ($this->User->validates()) {
$mail_data = $this->User->save($this->request->data);


$owneremail = $this->request->data['info@gmail.com'];
$from = $owneremail;
$subject = "Technician registration";
$user_name = $mail_data['User']['name'];
$email_user = $mail_data['User']['email'];
$password = $this->request->data['User']['password'];
$to = array($mail_data['User']['email']);
$mail_content = __('Name:', 'beopen') . $user_name . PHP_EOL .
__('Email:', 'beopen') . $email_user . PHP_EOL .
__('Password:', 'beopen') . $password . PHP_EOL .
__($url = Router::url(array("controller" => "users", "action" => "login"), true));

sendEmail($from, $user_name, $to, $subject, $mail_content);

$msg = '<div class="alert alert-success">
<button type="button" class="close" data-dismiss="alert">&times;</button>
<strong> User Created succeesfully </strong>
</div>';
} else {
$msg = $this->generateError($this->User->validationErrors);
}
$this->Session->setFlash($msg);
// return $this->redirect('create');
}
$this->set('roles', $this->Role->find("list"));
}

通过此代码我无法从管理员邮件地址发送电子邮件

最佳答案

打印数组:$this->request->data。我认为没有像 info@gmail.com 这样的索引 您似乎尝试在 from 属性中设置电子邮件。所以只需将电子邮件分配给 $from。试试这个:

第 1 步:删除 $owneremail = $this->request->data['info@gmail.com'];

step2: 将$from = $owneremail; 改为

  $from = 'info@gmail.com';

N.B: 学习数组基础,设置真实邮件来测试邮件功能。

关于php - cakePHP发送的电子邮件,如何在变量中设置管理员电子邮件地址?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34336977/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com