dongshi6528 2016-09-28 08:03
浏览 32

从选定的人那里获取电子邮件并发送自动电子邮件

I'm working on a project. A Costumer who visits the company needs to select the employee he has an appointment with. Now if he selects him and presses submit, the employee should get an e-mail with the message that his appointment has arrived.

so i have this :

<form action="mail.php">
<select id="email" name="email">
    <?php
    //laat de lijst zien van namen van medewerkers, hier zit ook een e-mail aan gekoppeld.

    define('Include',TRUE);
    require 'database.php';//Needed for database connection

    $query= "SELECT employee, email FROM email_register ORDER BY employee ASC";
    $result= mysqli_query($db_con, $query);

    echo "<option value='' disabled selected>Selecteer uw contactpersoon</option>";

    while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)){
    $employee=$row["employee"];
    $email=$row["email"];
        echo " <option>$employee</option>";
    }
    ?>
</select>
<br/></br>
<button type="submit" name="verzenden">Aanmelden</button>
</form>

which selects a person from a database. The table includes: ID, Employee and Email.

then when you press submit, the email which is attached to the person, should go in the following script and send an email. so on the lines of "EMPLOYEE@email.com" and "name employee" the selected data should be filled in. Now someone told me i had to use javascript/jquery. But im not that familiair with those languages since i'm still a newbie

<?php
require 'phpmailer/PHPMailerAutoload.php';

$mail = new PHPMailer;

//$mail->SMTPDebug = 3;                               // Enable verbose debug output

$mail->isSMTP();                                      // Set mailer to use SMTP
$mail->Host = 'smtp-pulse.com';  // Specify main and backup SMTP servers
$mail->SMTPAuth = true;                               // Enable SMTP authentication
$mail->Username = 'EMAIL@gmail.com';                 // SMTP username
$mail->Password = 'PASSWORD';                           // SMTP password
$mail->SMTPSecure = 'ssl';                            // Enable TLS encryption, `ssl` also accepted
$mail->Port = 111;                                    // TCP port to connect to

$mail->setFrom('EMAIL@gmail.com ', 'name sender');
$mail->addAddress('EMPLOYEE-MAIL@mail.com', 'name employee');     // Add a recipient

$mail->isHTML(true);                                  // Set email format to HTML

$mail->Subject = 'Bezoek';
$mail->Body    = 'Beste, <br/><br/> some text ment for the employee;

if(!$mail->send()) {
    echo 'Message could not be sent.';
    echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
    echo 'Message has been sent';
}
?>

so i'm wondering if anyone could help me out. or send me in the right direction

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 如何在scanpy上做差异基因和通路富集?
    • ¥20 关于#硬件工程#的问题,请各位专家解答!
    • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
    • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
    • ¥30 截图中的mathematics程序转换成matlab
    • ¥15 动力学代码报错,维度不匹配
    • ¥15 Power query添加列问题
    • ¥50 Kubernetes&Fission&Eleasticsearch
    • ¥15 報錯:Person is not mapped,如何解決?
    • ¥15 c++头文件不能识别CDialog