我建立了一个客户数据库,我希望增加向客户发送固定通知的可能性。首先,我想将数据发送到确认站点,该站点还显示我们的数据库中保存了哪些数据,并且需要确认是否发送。点击提交后,它应该发送电子邮件。
现在我从e-mail.php进入sendmail.php时收到HTTP ERROR 500
不幸的是,我似乎无法为电子邮件字段提供变量?我非常确定我的知识太有限了,但如果有人给我一个建议我会很感激。谢谢! :)
这是简短的表格代码(email.php):
<form method="POST" action="sendmail.php">
<input type="hidden" name="id" name="id" value="<?php print $id; ?>">
Are you sure to send a notification to <strong><?php print $cegnev; ?></strong>?
<input type="hidden" name="cegnev" value="<?php print $cegnev; ?>"> <br> Hidden input contains: <?php print $cegnev; ?>
<input type="hidden" name="email" value="<?php print $email; ?>"> <br> Hidden input contains: <?php print $email; ?>
<input type="hidden" name="szamla_datum" value="<?php print $szamla_datum; ?>"> <br> Hidden input contains: <?php print $szamla_datum; ?>
<input type="submit" name="elkuld">
这是sendmail.php:
<?php
if(isset($_POST['elkuld'])) {
$cegnev = $_POST['cegnev'];
$email = $_POST['email'];
$szamla_datum = $_POST['szamla_datum'];
}
$mail = new EMail;
//Enter your SMTP server (defaults to "127.0.0.1"):
$mail->Server = "host";
//Enter your FULL email address:
$mail->Username = 'username';
//Enter the password for your email address:
$mail->Password = 'password';
//Enter the email address you wish to send FROM (Name is an optional friendly name):
$mail->SetFrom("from email","from name");
//Enter the email address you wish to send TO (Name is an optional friendly name):
$mail->AddTo $email; // #### PROBLEM
//You can add multiple recipients:
// $mail->AddTo("someother2@address.com");
//Enter the Subject of your message:
$mail->Subject = $cegnev; // #### PROBLEM
//Enter the content of your email message:
$mail->Message = $szamla_datum; // #### PROBLEM
//Optional extras
$mail->ContentType = "text/html"; // Defaults to "text/plain; charset=iso-8859-1"
//$mail->Headers['X-SomeHeader'] = 'abcde'; // Set some extra headers if required
echo $success = $mail->Send(); //Send the email.
?>
答案 0 :(得分:1)
当代码中存在某种语法错误时,通常会出现500错误,在本例中为
你的话在这里:
$mail->AddTo $email;
需要,假设电子邮件是正确的变量
$mail->AddTo = $email;
或$mail->AddTo($email);
无论是类中的变量还是函数