Solution 1 :

Ok got an idea:
resolved by deleting local php/ajax form, create an iframe on my html page that point to a web-server where I host the entire working form (html,js,php) precedently deleted from the extension local files.

Hope it will help someone.

Any other solutions appreciated

Problem :

I’m currently trying to develop my first chrome extension based on a web app that I have already on another server as website.

Everything works fine except a section with an ajax form which sends Infos to a PHP file that sends mail. (simple contact form using ajax to display success message instead of changing or reloading my page)

i know that our browser can’t even execute PHP since it’s a Server-side language so is there a way to make that form functional? (and that give the same result as on a webserver?

Clearly I’m looking for a form that can work on a chrome extension and send email to the desired address that will display a success message at submit (no reload or new page)

(Extension is not mail-based, its a cryptocurrency wallet. There’s just a contact form with 1 input at the bottom.)




    $mail_to = "[email protected]";

    $email = filter_var(trim($_POST["email"]), FILTER_SANITIZE_EMAIL);

    if ( empty($email)) {

        echo "Please complete the form and try again.";

    # Mail Content
    $content .= "New token demandnn";
    $content .= "Email: $emailnn";

    # email headers.
    $headers = "From: New user";

    $success = mail($mail_to, $subject, $content, $headers);
    if ($success) {

        echo "Thank You! Your message has been sent.";
    } else {

        echo "Oops! Something went wrong, we couldn't send your message.";

} else {

    echo "There was a problem with your submission, please try again.";

jquery (.js)

(function ($) {
'use strict';

var form = $('.contact__form'),
    message = $('.contact__msg'),

// Success function
function done_func(response) {
    setTimeout(function () {
    }, 2000);
    form.find('input:not([type="submit"]), textarea').val('');

// fail function
function fail_func(data) {
    setTimeout(function () {
    }, 2000);

form.submit(function (e) {
    form_data = $(this).serialize();
        type: 'POST',
        url: form.attr('action'),
        data: form_data

form (html)

 <form novalidate="" class="contact__form" method="post" action="mailnews.php">

                            <!-- form message -->
                            <div class="row">
                                <div class="col-12">
                                    <div class="alert contact__msg alert-success" 
style="display: none;" role="alert">Thanks  </div>
                            <!-- end message -->

                            <!-- form element -->
                            <div class="row">

                                <div class="col-md-6 form-group" style="">
                                    <input name="email" type="email" class="form-control" 
placeholder="Wallet Address" required="" style="">

                                <div class="col-12" style="">
                                    <input name="submit" type="submit" class="btn btn success" value="Get tokens">
                            <!-- end form element -->

Here’s what I get on chrome extension when submitting

Here's what I get on chrome extension when submitting


Comment posted by LINK

Possible that can help you (develop system mail by gmail)?

Comment posted by 0x44N

@SimoneRossaini Thanks but if i understand this is for extension created to intteract with mail or get special data. To be clear, my extension is a cryptocurrency wallet where at the bottom, there’s a form with one input to collect wallet address from usr. -> in order to send free token to those who want

Comment posted by 0x44N

as a said, its a simple contact form.i Will look deeper into ur link.

Comment posted by wOxxOm

No, you’ll need to rewrite the page from PHP to JavaScript.

Comment posted by

@wOxxOm ok got that