• sacconi

    (@sacconi)


    Is this code correct?

                    <?php
    $subject= $post->ID;

    $message= esc_html__('Don\'\t forget to insert the number of people','sacconicase');

    echo '<form><a href=\"mailto: subject=$subject&body=$message\"><input type="button" class="listino" value=" '. esc_html__('Availability','sacconicase').' " ></a></form>';

    ?>

    When I click on a specific button an email container should open with for subject the post ID of that specific page, and in the body a gettexted message

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator threadi

    (@threadi)

    Even if it is syntactically correct, no, I would not use it that way for several reasons:

    a) The form around it is completely unnecessary.
    b) The space after mailto: can be a problem.
    c) Labeling the link as a button is not really useful in terms of accessibility, for example.

    It would be better to use:

    <?php
    $subject= $post->ID;

    $message= esc_html__('Don\'\t forget to insert the number of people','sacconicase');

    echo '<a href=\"mailto:subject=$subject&body=$message\">'. esc_html__('Availability','sacconicase').'</a>';

    ?>

    But that doesn’t make it right. Because with this approach, you are preventing many of your visitors from contacting you at all. Not everyone has an email program on their computer or cell phone that would start when they click on this link. Those visitors would only see a message from their browser saying “unknown protocol” or something similar – and you would have lost them as potential customers.

    Instead, I would recommend using contact forms. There are many plugins to choose from: https://wordpress.org/plugins/tags/contact-form/

    Thread Starter sacconi

    (@sacconi)

    I already have a contact page, this is a temporary solution until I implement the search by date/calendars tool, maybe in one year. I never use contact forms because in my experience people make a lot of errors in typing and I simply cant reply…and nowadays who hasnt at least a gmail in his telephone? Mail is a default tool

    Thread Starter sacconi

    (@sacconi)

    Anyway the code is not working even after removing the space after mailto:

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘function to send predefined mails’ is closed to new replies.