2016-10-02 99 views
-2

我目前正在使用登錄和註冊功能的網站。現在,客戶希望通過電子郵件發送給他的所有用戶信息,並且我不知道如何將數據庫用戶信息發送到他的電子郵件中。如果任何人有關於如何做到這一點的想法,請協助我。發送數據庫用戶信息到電子郵件

回答

0

您可以使用郵件程序庫將用戶數據發送到客戶端。我以前親自使用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 = '[email protected]';     // 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('[email protected]', 'Mailer'); 
$mail->addAddress('[email protected]', '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('[email protected]', 'New user: username', 'somebody registered');