So I have a function in my wordpress custom theme witch I am using in all my forms. This function is in my wordpress functions.php and look like :
function mail_utf8($to, $subject = '(No subject)', $message = '', $from , $header = '') {
$header_ = "From: $from" . "\r\n" . 'MIME-Version: 1.0' . "\r\n" . 'Content-type: text/plain; charset=UTF-8' . "\r\n";
mail($to, '=?UTF-8?B?'.base64_encode($subject).'?=', $message, $header_ . $header);
}
So the question is – Does this function is executing all the time, when some on refresh page? Or the function is executing only when I call it?
Because, I am getting from my host massages, that I have exceed the mail limit every hour. When I removed this function and hard coded in every form, everything is all right.
I tried :
if( !empty( $message ) ) {
function mail_utf8($to, $subject = '(No subject)', $message = '', $from , $header = '') {
$header_ = "From: $from" . "\r\n" . 'MIME-Version: 1.0' . "\r\n" . 'Content-type: text/plain; charset=UTF-8' . "\r\n";
mail($to, '=?UTF-8?B?'.base64_encode($subject).'?=', $message, $header_ . $header);
}
}
but it didnt work
If you don’t have an opcode cache, this code is going to be parsed each time someone loads the page (loads/includes the file containing this code).
But it’s only going to be executed when someone calls it.
Note: there is no point of specifying default arguments before
$frombecause that field is mandatory.