gpt4 book ai didi

javascript - 使用 PHP 通过电子邮件发送表单数据

转载 作者:行者123 更新时间:2023-11-28 18:12:52 24 4
gpt4 key购买 nike

我收到了要发送到正确电子邮件的电子邮件,但他们正在发送此邮件。

电子邮件:$email
用户名:$用户名
密码:$密码
确认密码:$cpassword
主题标签:$主题标签

它没有发送表单中的数据。这是我的代码:

<form action="PHPMailer/gmail.php" method="POST">
<div class="form-style-8">
<span class="close">&times;</span>
<label for="mail">E-mail:</label>
<input type="email" id="mail" name="email"/>
</div>
<div>
<label for="msg">Username:</label><br>
<input id="user" name="username"></textarea>
</div>
<div>
<label for="msg">Password:</label><br>
<input type="password" id="pass" name="password"></textarea>
</div>
<div>
<label for="msg">Confirm Password:</label><br>
<input type="password" id="pass" name="cpassword"></textarea>
</div>
<div>
<label for="msg">3 Hashtags:</label><br>
<input id="tags" name="hashtags"></textarea>
</div>
<div>
<input id="submit" type="submit" name="submit" value="Login To Instagram">
</div>
</form>

PHP 代码在这里:

<?php
require 'PHPMailerAutoload.php';

$mail = new PHPMailer;
$email = $_POST['email'];
$username = $_POST['username'];
$password = $_POST['password'];
$cpassword = $_POST['cpassword'];
$hashtags = $_POST['hashtags'];

//$mail->SMTPDebug = 3; // Enable verbose debug output
$mail->IsSMTP();
$mail->Host = 'My Host Name Here'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'My SMTP Username'; // SMTP username
$mail->Password = 'My SMTP Password'; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 25; // TCP port to connect to

$mail->setFrom('myemailhere', 'mynamehere');
$mail->addAddress('$email', 'Customer'); // Add a recipient
//$mail->addReplyTo('info@example.com', 'Information');
$mail->addCC('myemailhere');
$mail->addBCC('$email');

//$mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments
//$mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name
$mail->isHTML(true); // Set email format to HTML

$mail->Subject = 'Subject';
$mail->Body = 'Email: $email <br> Username: $username <br> Password: $password <br> Confirm Password: $cpassword <br> Hasgtags: $hashtags';
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';

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

我只是想将从表单中收集的数据输入到 php 中,以便它可以通过电子邮件向我发送表单信息。谢谢

最佳答案

您使用了单引号。单引号内的变量不会被解析。

这会起作用:

$mail->Body    = "Email: $email <br> Username: $username <br> Password: $password <br> Confirm Password: $cpassword <br> Hasgtags: $hashtags";

关于javascript - 使用 PHP 通过电子邮件发送表单数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41290436/

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