wordpress - 由于端点不安全,带有 mailto 操作的 HTML 表单不起作用
问题描述
我正在尝试通过直接在模板块上键入 html 代码来制作 wordpress 表单(这与所需的视觉设计完全匹配)并且它不起作用。我在 chrome 控制台上收到此错误消息:
混合内容:“https://protegetumarcaonline.com/”上的页面是通过安全连接加载的,但包含针对不安全端点“mailto:proyectosonline@isern.com”的表单。该端点应通过安全连接提供。
https://photos.app.goo.gl/687cUavnacTQ94fF7
这是表单代码:
<form action="mailto:proyectosonline@isern.com" method="get" enctype="text/plain">
SOBRE TI <br><br>
Nombre*<br>
<input style="width:100%;" type="text" name="nombre" required="" class="czr-focusable">
Email*<br>
<input style="width:100%;" type="text" name="email" required="" class="czr-focusable">
¿Tienes web?<br>
<input style="width:100%;" type="text" name="web" class="czr-focusable">
Marca*
<input style="width:100%;" type="text" name="marca" required="" class="czr-focusable">
Productos y/o Servicios de interés*
<textarea style="width: 100%; margin-top: 0px; margin-bottom: 0px; height: 82px;" name="mensaje" required="" class="czr-focusable"> </textarea>
<input type="checkbox" name="Facebook"> Facebook<br>
<input type="checkbox" name="Instagram"> Instagram<br>
<input type="checkbox" name="Twitter"> Twitter<br>
<input type="checkbox" name="Web propia"> Web propia<br>
<input type="checkbox" name="Amazon"> Amazon<br>
<input type="checkbox" name="Alibaba"> Alibaba<br>
<input type="checkbox" name="Otras"> Otras<br>
<input type="checkbox" required="" name="politica"> Acepto la política de privacidad*<br>
<input type="checkbox" name="comunicaciones"> Acepto recibir comunicaciones comerciales e informativas<br><br>
<input type="image" src="wp-content/uploads/2020/11/icono-ENVIAR.png" value="Enviar" name="enviar" alt="Enviar" width="110 style=" border:="" none;"="">
我也尝试使用方法 post 并获得相同的结果。该网站是:https ://protegetumarcaonline.com/
我能做什么?
非常感谢,米格尔·吉斯伯特
解决方案
无法通过安全连接使用“mailto:”,因为 mailto: 打开了一个应用程序来发送邮件。可能使用或不使用安全协议 (TLS) 的应用程序。
解决此问题的一种方法是使用调用 PHP 脚本发送邮件的 POST 表单。所以你的 HTML 看起来像这样:
<form method="post" action="/wp-content/php_scripts/send_mail.php">
SOBRE TI <br><br>
Nombre*<br>
<input style="width:100%;" type="text" name="nombre" required="" class="czr-focusable">
Email*<br>
<input style="width:100%;" type="text" name="email" required="" class="czr-focusable">
¿Tienes web?<br>
<input style="width:100%;" type="text" name="web" class="czr-focusable">
Marca*
<input style="width:100%;" type="text" name="marca" required="" class="czr-focusable">
Productos y/o Servicios de interés*
<textarea style="width: 100%; margin-top: 0px; margin-bottom: 0px; height: 82px;" name="mensaje" required="" class="czr-focusable"> </textarea>
<input type="checkbox" name="Facebook"> Facebook<br>
<input type="checkbox" name="Instagram"> Instagram<br>
<input type="checkbox" name="Twitter"> Twitter<br>
[...]
<input type="submit">
</form>
还有你的 PHP 文件 send_mail.php
<?php
/**
* Filter the mail content type.
*/
function wpdocs_set_html_mail_content_type() {
return 'text/html';
}
add_filter( 'wp_mail_content_type', 'wpdocs_set_html_mail_content_type' );
$message = '<p>Nombre:' . $_POST['nombre'] . '</p><p>Email:' . $_POST['email'] .'</p><p>...</p>';
$result = wp_mail('proyectosonline@isern.com', 'New mail', $message);
if ($result ) {
// Do something here
}
// Reset content-type to avoid conflicts -- https://core.trac.wordpress.org/ticket/23578
remove_filter( 'wp_mail_content_type', 'wpdocs_set_html_mail_content_type' );
?>
wp_mail 文档:https ://developer.wordpress.org/reference/functions/wp_mail/
wp_mail_content_type:https ://developer.wordpress.org/reference/hooks/wp_mail_content_type/
推荐阅读
- uno-platform - Uno - 在运行时动态加载布局
- arrays - 如何将数组从章鱼变量传递给 azure arm 模板参数
- django - 如何覆盖 dj-rest-auth 和 all-auth 中的验证电子邮件功能?
- qt - 如何创建具有多种颜色的 qt QTButton?
- r - 做什么
在小标题中是什么意思? - flutter - Flutter TZDateTime 返回当前时间
- javascript - 停止通过 REST、表单数据、JavaScript 和 Axios 发送带有文件的 Content-Disposition
- azure - 如何在 main.tf 中执行一个 Terraform 模块
- sql - 使用 T-SQL,如何列出两个表的列并指示列是否被索引?
- python - 使用python打开密码文件?