gpt4 book ai didi

PHP 页面不发送电子邮件

转载 作者:行者123 更新时间:2023-11-28 01:46:06 25 4
gpt4 key购买 nike

我有一个页面,其中有一个表单供用户输入他们的电子邮件。提交表单后,电子邮件将在我的 MSSQL 表中进行检查,如果它存在于表的行之一中,它将向用户的电子邮件发送一封电子邮件。现在,我正确地输入了一封现有的电子邮件,但从未收到过该电子邮件。我试图这样做,以便如果用户忘记了他们的密码,它将从正确的行中检索密码并将该密码发送到用户的电子邮件。

这是我的 PHP 页面代码:

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
</head>

<body>
<?php
$conn=mssql_connect('gdm','dr','Rd1!');
mssql_select_db('Gdr',$conn);
if (isset($_POST['forgotpass'])) {
$conn=mssql_connect('gdom','GBdr','d1!');
mssql_select_db('Gdr',$conn);
if (!get_magic_quotes_gpc()) {

$_POST['email'] = addslashes($_POST['email']);

}

$email = $_POST['email'];
$querye = "SELECT password FROM staffportal WHERE email = '".$_POST['email']."'";
$check = mssql_query($querye, $conn);
$check2 = mssql_num_rows($check);
echo "".$check2."";
//if the email doesn't exist it gives an error
if ($check2 != 0) {
print"<p>Thank you, dsa we will get back to you.</p>";
print"<p>Today's date isdsa.</p>";
ob_start();
$tae = "".$_POST['email']."";
echo "".$tae."";
$out2 = ob_get_contents();
ob_end_clean();
var_dump($out2);
var_dump($out2);
$to = "".$out2."";
echo "Emailing to: ".$to."";
$subject = "Financing fordsac ";
$body = "dsdasd \n\n";
$headers = "From: info@gbmtd.ca";
mail($to, $subject, $body, $headers);
} else {
echo "Sorry, the email ".$email." is incorrect.";
} } else {
?>
<form method="POST" action="<?php $_PHP_SELF ?>">
Email:<br />
<input type="text" name="email" id="email"/>
<br /><br />
<input type="submit" id="forgotpass" value="Change Password" name="forgotpass"/>
</form>
<?php } ?>
</body>
</html>

这会在我点击提交后显示在我的页面上:

1
Thank you, dsa we will get back to you.

Today's date isdsa.

string(22) "kelseynealon@gmail.com" string(22) "kelseynealon@gmail.com" Emailing to: kelseynealon@gmail.com

非常感谢所有帮助。感谢您的帮助。

最佳答案

我在使用 PHP 邮件功能时运气不佳。 PHP邮件功能页面可以看看http://www.php.net/manual/en/function.mail.php寻找线索。我个人使用 PHP SwiftMailer ( http://swiftmailer.org/ ) 来处理从 PHP 应用程序发送的任何电子邮件,它工作得非常好。

这是我使用它的通用函数:

/*
Starting code for sending email via this function:
list($email_logger, $email_mailer) = email_interface();
$message = Swift_Message::newInstance()
->setFrom(array('from@domain.ext' => 'John Doe'))
->setTo(array('to@domain.ext' => 'Jane Doe'))
->setSubject('<SUBJECT>')
->setBody('<BODY>');
$email_mailer->send($message);
*/

// Returns PHP SwiftMailer mailer and logger email interfaces
function email_interface()
{

// Mail configuration
$global_email_config = array(
//'relay_encryption' => 'ssl',
//'relay_host' => 'relayhost.domain.ext',
//'relay_port' => '465',
// 'relay_user' => '<ADDR>',
// 'relay_pass' => '<PASS>',
'smtp_sender' => array(
'sender@domain.ext' => 'Sender Name'
)
);

if (isset($global_email_config['relay_host'])) {
$transport = Swift_SmtpTransport::newInstance();
$transport->setHost($global_email_config['relay_host']);

if (isset($global_email_config['relay_port'])) {
$transport->setPort($global_email_config['relay_port']);
}

if (isset($global_email_config['relay_encryption'])) {
$transport->setEncryption($global_email_config['relay_encryption']);
}

if (isset($global_email_config['relay_user'])) {
$transport->setUsername($global_email_config['relay_user']);
$transport->setPassword($global_email_config['relay_pass']);
}

} else {
$transport = Swift_SendmailTransport::newInstance();
}

$mailer = Swift_Mailer::newInstance($transport);
$logger = new Swift_Plugins_Loggers_ArrayLogger();
$mailer->registerPlugin(new Swift_Plugins_LoggerPlugin($logger));

return array(
$logger,
$mailer
);
}

关于PHP 页面不发送电子邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22565467/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com