Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8548669
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T13:32:51+00:00 2026-06-11T13:32:51+00:00

I’m trying to make MailHandler.php to work with WordPress. I have tried a dozen

  • 0

I’m trying to make MailHandler.php to work with WordPress. I have tried a dozen of solutions but non of them worked. Here are the workarounds that I did with the “forms.js” file I’ve tried:

1.) Change “bin/MailHandler.php” to “mail/mailhandler.php”

  1. ) Here are some original codes that I have changed too:

mailHandlerURL:’../mail/mailhandler.php’ was changed to

mailHandlerURL:’http://www.mysite.net/wp-content/themes/mysite/mail/mailhandler.php’,

THEN ALSO TRIED:

mailHandlerURL:’<?php echo get_template_directory_uri(); ?>/mail/mailhandler.php’,

In the contact_template.php is where my form is located. Here are some things I tried for the form action and none of them worked:

 **<form action="../mail/mailhandler.php" id="contact-form">** Changed to

 **<form action="http://www.mysite.net/wp-content/themes/mysite/mail/mailhandler.php" id="contact-form">**

AND

<form action="<?php echo get_template_directory_uri(); ?>/mail/mailhandler.php" id="contact-form">

Please help.

By the way my smtpMailServer is set to localhost inside my forms.js.

Thanks in advance.

ADDITIONAL INFO

Below are the codes of my mailhandler.php

<?php
$owner_email = $_POST["me@mysite.com"]; /*/originally owner_email/*/
$headers = 'From:' . $_POST["email"];
$subject = 'A message from your site visitor ' . $_POST["name"];
$messageBody = "";

if($_POST['name']!='nope'){
    $messageBody .= '<p>Visitor: ' . $_POST["name"] . '</p>' . "\n";
    $messageBody .= '<br>' . "\n";
}
if($_POST['email']!='nope'){
    $messageBody .= '<p>Email Address: ' . $_POST['email'] . '</p>' . "\n";
    $messageBody .= '<br>' . "\n";
}
if($_POST['phone']!='nope'){        
    $messageBody .= '<p>Phone Number: ' . $_POST['phone'] . '</p>' . "\n";
    $messageBody .= '<br>' . "\n";
}   
if($_POST['message']!='nope'){
    $messageBody .= '<p>Message: ' . $_POST['message'] . '</p>' . "\n";
}

if($_POST["stripHTML"] == 'true'){
    $messageBody = strip_tags($messageBody);
}

try{
    if(!mail($owner_email, $subject, $messageBody, $headers)){
        throw new Exception('mail failed');
    }else{
        echo 'mail sent';
    }
}catch(Exception $e){
    echo $e->getMessage() ."\n";
}

?>

Here is what inside forms.js:

(function($){
$.fn.extend({
    forms:function(opt){
        if(opt===undefined)
            opt={}
        this.each(function(){
            var th=$(this),
                data=th.data('forms'),
                _={
                    errorCl:'error',
                    emptyCl:'empty',
                    invalidCl:'invalid',
                    successCl:'success',
                    successShow:'4000',
                    mailHandlerURL:'http://www.mysite.com/wp-content/themes/mysite/mail/mailhandler.php',
                    ownerEmail:'me@mysite.com',
                    stripHTML:true,
                    smtpMailServer:'localhost',
                    targets:'input,textarea',
                    controls:'a[data-type=reset],a[data-type=submit]',
                    validate:true,
                    rx:{
                        ".name":{rx:/^[a-zA-Z'][a-zA-Z-' ]+[a-zA-Z']?$/,target:'input'},
                        ".email":{rx:/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i,target:'input'},
                        ".phone":{rx:/^\+?(\d[\d\-\+\(\) ]{5,}\d$)/,target:'input'},
                        ".message":{rx:/.{20}/,target:'textarea'}
                    },
                    preFu:function(){
                        _.labels.each(function(){
                            var label=$(this),
                                inp=$(_.targets,this),
                                defVal=inp.val(),
                                trueVal=(function(){
                                            var tmp=inp.is('input')?(tmp=label.html().match(/value=['"](.+?)['"].+/),!!tmp&&!!tmp[1]&&tmp[1]):inp.html()
                                            return defVal==''?defVal:tmp
                                        })()
                            trueVal!=defVal
                                &&inp.val(defVal=trueVal||defVal)
                            label.data({defVal:defVal})                             
                            inp
                                .bind('focus',function(){
                                    inp.val()==defVal
                                        &&(inp.val(''),_.hideEmptyFu(label),label.removeClass(_.invalidCl))
                                })
                                .bind('blur',function(){
                                    !inp.val()
                                        ?inp.val(defVal)                                        
                                        :(_.isValid(label)
                                            ?_.showErrorFu(label)
                                            :_.hideErrorFu(label)),
                                        (_.isEmpty(label)
                                            ?_.showEmptyFu(label)
                                            :_.hideEmptyFu(label))
                                })
                                .bind('keyup',function(){
                                    label.hasClass(_.invalidCl)
                                        &&_.isValid(label)
                                            ?_.showErrorFu(label)
                                            :_.hideErrorFu(label)
                                })
                            label.find('.'+_.errorCl+',.'+_.emptyCl).css({display:'block'}).hide()
                        })
                        _.success=$('.'+_.successCl,_.form).hide()
                    },
                    isValid:function(el){
                        var ret=true,
                            empt=_.isEmpty(el)
                        if(empt)
                            ret=false,
                            el.addClass(_.invalidCl)
                        else
                            $.each(_.rx,function(k,d){
                                if(el.is(k))
                                    d.rx.test(el.find(d.target).val())
                                        ?(el.removeClass(_.invalidCl),ret=false)
                                        :el.addClass(_.invalidCl)
                            })
                        return ret
                    },
                    isEmpty:function(el){
                        var tmp
                        return (tmp=el.find(_.targets).val())==''||tmp==el.data('defVal')
                    },
                    validateFu:function(){                          
                        _.labels.each(function(){
                            var th=$(this)                              
                            _.isEmpty(th)
                                ?_.showEmptyFu(th)
                                :_.hideEmptyFu(th)
                            _.isValid(th)
                                ?_.showErrorFu(th)
                                :_.hideErrorFu(th)
                        })
                    },
                    submitFu:function(){
                        _.validateFu()
                        if(!_.form.has('.'+_.invalidCl).length)
                            $.ajax({
                                type: "POST",
                                url:_.mailHandlerURL,
                                data:{
                                    name:$('.name input',_.form).val()||'nope',
                                    email:$('.email input',_.form).val()||'nope',
                                    phone:$('.phone input',_.form).val()||'nope',
                                    fax:$('.fax input',_.form).val()||'nope',
                                    state:$('.state input',_.form).val()||'nope',
                                    message:$('.message textarea',_.form).val()||'nope',
                                    owner_email:_.ownerEmail,
                                    stripHTML:_.stripHTML
                                },
                                success: function(){
                                    _.showFu()
                                }
                            })          
                    },
                    showFu:function(){
                        _.success.slideDown(function(){
                            setTimeout(function(){
                                _.success.slideUp()
                                _.form.trigger('reset')
                            },_.successShow)
                        })
                    },
                    controlsFu:function(){
                        $(_.controls,_.form).each(function(){
                            var th=$(this)
                            th
                                .bind('click',function(){
                                    _.form.trigger(th.data('type'))
                                    return false
                                })
                        })
                    },
                    showErrorFu:function(label){
                        label.find('.'+_.errorCl).slideDown()
                    },
                    hideErrorFu:function(label){
                        label.find('.'+_.errorCl).slideUp()
                    },
                    showEmptyFu:function(label){
                        label.find('.'+_.emptyCl).slideDown()
                        _.hideErrorFu(label)
                    },
                    hideEmptyFu:function(label){
                        label.find('.'+_.emptyCl).slideUp()
                    },
                    init:function(){
                        _.form=this
                        _.labels=$('label',_.form)

                        _.preFu()

                        _.controlsFu()

                        _.form
                            .bind('submit',function(){
                                if(_.validate)
                                    _.submitFu()
                                else
                                    _.form[0].submit()
                                return false
                            })
                            .bind('reset',function(){
                                _.labels.removeClass(_.invalidCl)                                   
                                _.labels.each(function(){
                                    var th=$(this)
                                    _.hideErrorFu(th)
                                    _.hideEmptyFu(th)
                                })
                            })
                        _.form.trigger('reset')
                    }
                }
            if(!data)
                (typeof opt=='object'?$.extend(_,opt):_).init.call(th),
                th.data({cScroll:_}),
                data=_
            else
                _=typeof opt=='object'?$.extend(data,opt):data
        })
        return this
    }
})




})(jQuery)
$(document).ready(function(){
$('#contact-form').forms({
    ownerEmail:'me@mysite.com'
})
});
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T13:32:52+00:00Added an answer on June 11, 2026 at 1:32 pm

    This line $owner_email = $_POST["me@mysite.com"]; /*/originally owner_email/*/ is funny. I’m pretty sure that POST variable won’t exist.

    Try $owner_email = $_POST["owner_email"];.

    Or did you actually mean to statically/permanently change the value of $owner_email to “me@mysite.com”? If so you want to set it to the string, $owner_email = "me@mysite.com";, and NOT the POST variable called “me@mysite.com”…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into
This could be a duplicate question, but I have no idea what search terms
I'm trying to create an if statement in PHP that prevents a single post
I am trying to loop through a bunch of documents I have to put
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I am trying to understand how to use SyndicationItem to display feed which is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.