【发布时间】:2016-04-27 09:54:19
【问题描述】:
我想在表格中输入电子邮件和公司名称,然后必须将随机生成的密码发送到给定的电子邮件。
以下是我生成随机密码和发送电子邮件的代码。
<?php
$company_name = "";
$email = "";
if (isset($_POST['submit'])) {
$company_name = $_POST["company_name"];
$email = $_POST["email_address"];
$chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%&*_";
$password = substr(str_shuffle($chars), 0, 8);
$to = $email;
$subject = 'your registration is completed';
$message = 'Welcome' . $company_name . ''
. 'Your email and password is following :'
. 'Email:' . $email . ''
. 'Your new password : ' . $password . ''
. 'Now you can login with this email and password';
$headers = 'From :' . $email . "\r\n";
mail($to, $subject, $message, $headers);
}
?>
但这显示了以下错误。
Warning: mail() [function.mail]: "sendmail_from" not set in php.ini or custom "From:" header missing in "path"\password_generation.php on line 21
第 21 行是mail($to, $subject, $message, $headers);
【问题讨论】: