【问题标题】:Sending Database User Info Into Email [duplicate]将数据库用户信息发送到电子邮件 [重复]
【发布时间】:2016-10-02 13:08:36
【问题描述】:

我目前正在开发一个具有登录和注册功能的网站。现在,客户希望通过电子邮件将所有用户信息发送给他,而我不知道如何将数据库用户信息发送到他的电子邮件中。如果有人对我如何做到这一点有任何想法,请帮助我。

【问题讨论】:

    标签: php


    【解决方案1】:

    您可以使用邮件程序库将用户数据发送到客户端。我之前亲自使用过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');
    

    【讨论】:

      猜你喜欢
      • 2016-01-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-05-23
      相关资源
      最近更新 更多