发送数据库用户信息到电子邮件


Sending Database User Info Into Email

我目前正在与登录和注册功能的网站工作。现在,客户端希望所有的用户信息通过电子邮件发送给他,我不知道如何将数据库用户信息发送到他的电子邮件。如果有人知道我该怎么做,请帮助我。

可以使用邮件库将用户数据发送到客户机。我个人以前使用过PHPMailer。

下面是他们github页面上的一个例子:

$mail = new PHPMailer;
$mail->isSMTP();                                      // Set mailer to use     SMTP
$mail->Host = 'smtp1.example.com;smtp2.example.com';  // Specify main and backup SMTP servers
$mail->SMTPAuth = true;                               // Enable SMTP    authentication
$mail->Username = 'user@example.com';                 // SMTP username
$mail->Password = 'secret';                           // SMTP password
$mail->SMTPSecure = 'tls';                            // Enable TLS encryption, `ssl` also accepted
$mail->Port = 587;                                    // TCP port to connect to
$mail->setFrom('from@example.com', 'Mailer');
$mail->addAddress('joe@example.net', 'Joe User');     // Add a recipient
$mail->Subject = 'Here is the subject';
$mail->Body    = 'This is the HTML message body <b>in bold!</b>';
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
if(!$mail->send()) {
    echo 'Message could not be sent.';
    echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
    echo 'Message has been sent';
}

或者有php mail函数http://php.net/manual/en/function.mail.php.

mail('client@email.com', 'New user: username', 'somebody registered');