如何从用户表中提取电子邮件地址并使用$_SESSION[user_id]
变量向该地址发送电子邮件?
在付款过程结束时,我想向用户发送确认电子邮件。用户 ID 存储在会话中,我想向存储在用户表中的电子邮件地址发送确认。
<?php
$to = "recipient@example.com";
$subject = "Hi!";
$body = "Hi,\n\nHow are you?";
if (mail($to, $subject, $body)) {
echo("<p>Message successfully sent!</p>");
} else {
echo("<p>Message delivery failed...</p>");
}
?>
如何使用查询插入与 $_SESSION[user_id] 变量关联的适当电子邮件?
$q = "SELECT email from users where id='".$_SESSION['user_id']."'";
$r = mysqli_query ($dbc, $q);
$to = "email";
$subject = "Confirmation";
$body = "Hi,\n\nConfirmation?";
if (mail($to, $subject, $body)) {
echo("<p>Message successfully sent!</p>");
} else {
echo("<p>Message delivery failed...</p>");
}
我已成功发送信息电子邮件,但电子邮件从未到达...在注册过程中,我使用以下方式发送电子邮件:
$body = "Thank you for registering at <...>. Welcome to digital world of knowledge.";
mail ($_POST['email'], 'Registration Confirmation', $body, 'From: admin@ttt.com');