Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/286.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何通过电子邮件发送元素';s值到一个地址_Php_Html_Phpmailer - Fatal编程技术网

Php 如何通过电子邮件发送元素';s值到一个地址

Php 如何通过电子邮件发送元素';s值到一个地址,php,html,phpmailer,Php,Html,Phpmailer,我之前问了一个被删除的问题,但是我现在对我想要的东西有了更好的想法,并且对我想要使用的代码有了一个想法。这个想法是,该人将能够输入一个想法,并将在提交表格时通过电子邮件将该想法发送给我。这是我使用PHPMailer想到的: <html> <head> <link rel="shortcut icon" href="https://cdn2.iconfinder.com/data/icons/thesquid-ink-40-free-flat-icon-pack/64

我之前问了一个被删除的问题,但是我现在对我想要的东西有了更好的想法,并且对我想要使用的代码有了一个想法。这个想法是,该人将能够输入一个想法,并将在提交表格时通过电子邮件将该想法发送给我。这是我使用PHPMailer想到的:

<html>
<head>
<link rel="shortcut icon" href="https://cdn2.iconfinder.com/data/icons/thesquid-ink-40-free-flat-icon-pack/64/rubber-duck-512.png" type="image/x-icon">
<title>Thank You!</title>
</head>
<body>
Your idea has been submitted! Thank you for the idea.
<a href="index.html"><button>Click to go back to the site!</button></a>
<?php
require 'PHPMailerAutoload.php';

$mail = new PHPMailer;

$mail->SMTPDebug = 3;                               

$mail->isSMTP();                                      // Set mailer to use SMTP
$mail->Host = 'smtp1.example.com;smtp2.example.com';  // Specify main and backup SMTP servers
$mail->SMTPAuth = true;                               // Enable SMTP authentication
$mail->Username = 'randomwordgenidea@gmail.com';                 // SMTP username
$mail->Password = 'ideaEmail';                           // SMTP password
$mail->SMTPSecure = 'tls';                            // Enable TLS encryption, `ssl` also accepted
$mail->Port = 587;                                    // TCP port to connect to

$mail->setFrom('randomwordgenidea@gmail.com');
$mail->addAddress('randomwordgenidea@gmail.com');
$mail->isHTML(true);                                  // Set email format to HTML

$mail->Subject = 'Idea';
$mail->Body    = echo $_GET["idea"];
$mail->AltBody = echo $_GET["idea"];
?>
</body>
<html>

非常感谢。
你的想法已经提交了!谢谢你的主意。
这是我用来访问文件的表单:

<h1 style="color:grey">Ideas</h1>
<form action="email.php">
<h3>Idea:</h3>
<input type="text" name="idea">
<input type="submit">
</form>
创意
想法:

但是它不起作用,我不确定我是否做得正确,如果有人能帮我调试代码,那就太好了!另外,如果有人知道更好的方法,请告诉我。

我在你的代码中没有看到任何东西真正发送你的信息。显示一个简单的示例,该示例显示如何实际发送您构建的消息:

$mail->send();

您可以尝试阅读一些文档,看看PHPMailer提供的Gmail示例。因此,这不是为您调试代码,而是帮助您了解如何自己调试。@Synchro Stack Overflow允许调试问题,只要这些问题有“所需的行为、特定的问题或错误,以及在问题本身中重现问题所需的最短代码”不过,我会看看gmail的例子,如果还有问题,我会回来找你。是的,你错过了大部分标准。@Synchro哦,不,事实上。我有尽可能少的代码以及代码的明确目的。不过这没关系,因为我似乎已经用你的建议修复了这个文件,所以我希望不需要进一步的帮助。这很有帮助,我从来没有想过要添加一条发送线,但幸好你能抓到它。