HTML-форма с действием mailto не работает из-за небезопасной конечной точки

Я пытаюсь создать форму WordPress, набрав непосредственно html-код в блоке шаблона (это точно соответствует требуемому визуальному дизайну), и это не работает. Я получаю это сообщение об ошибке на консоли Chrome:

Смешанное содержимое: страница «https://protegetumarcaonline.com/» была загружена через безопасное соединение, но содержит форму, нацеленную на небезопасную конечную точку «mailto:[email protected]». Эта конечная точка должна быть доступна через безопасное соединение.

https://i.stack.imgur.com/WQsNG.png

Это код формы:

<form action="mailto:[email protected]" 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/.

Что я мог сделать?

Большое спасибо, Мигель Гисберт.


person Miguel Gisbert    schedule 11.12.2020    source источник


Ответы (1)


Невозможно использовать mailto: с безопасным соединением, так как mailto: открывает приложение для отправки почты. Приложение, которое может использовать или не использовать безопасный протокол (TLS).

Один из способов исправить это — использовать форму POST, которая вызывает PHP-скрипт для отправки почты. Итак, ваш 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('[email protected]', '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/

person Thomas LIBERATO    schedule 11.12.2020
comment
Большое спасибо, Томас, теперь я получаю сообщение об ошибке 500 без сообщения на консоли Chrome. - person Miguel Gisbert; 12.12.2020
comment
Я установил все разрешения для файла send_mail.php. Что еще я мог сделать? Большое спасибо, - person Miguel Gisbert; 12.12.2020