Access to request from origin has been blocked by CORS policy. Email sending failed with this error...












-1
















This question already has an answer here:




  • How does Access-Control-Allow-Origin header work?

    13 answers



  • How to allow CORS?

    24 answers




I am not able to send email from my website (developed using HTML, CSS, JavaScript).



I get following error message when i send email:




Access to XMLHttpRequest at 'http://mobilfiksern.no/contactform.php' from origin 'http://www.mobilfiksern.no' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.




Can any one please help me to fix this issue?










share|improve this question















marked as duplicate by sideshowbarker cors
Users with the  cors badge can single-handedly close cors questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Jan 4 at 0:40


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.



















  • I guess the issue is because of www subdomain?

    – Priyank Panchal
    Jan 1 at 8:43











  • need to add headers

    – Shireesha Parampalli
    Jan 1 at 8:47











  • can you change your url from mobilfiksern.no/contactform.php to mobilfiksern.no/contactform.php this and retry.

    – Ved
    Jan 1 at 8:47











  • @ShireeshaParampalli what headers I should add?

    – Nadeem
    Jan 3 at 11:00











  • @Ved both of these are the same URLs, what url i should change?

    – Nadeem
    Jan 3 at 11:00
















-1
















This question already has an answer here:




  • How does Access-Control-Allow-Origin header work?

    13 answers



  • How to allow CORS?

    24 answers




I am not able to send email from my website (developed using HTML, CSS, JavaScript).



I get following error message when i send email:




Access to XMLHttpRequest at 'http://mobilfiksern.no/contactform.php' from origin 'http://www.mobilfiksern.no' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.




Can any one please help me to fix this issue?










share|improve this question















marked as duplicate by sideshowbarker cors
Users with the  cors badge can single-handedly close cors questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Jan 4 at 0:40


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.



















  • I guess the issue is because of www subdomain?

    – Priyank Panchal
    Jan 1 at 8:43











  • need to add headers

    – Shireesha Parampalli
    Jan 1 at 8:47











  • can you change your url from mobilfiksern.no/contactform.php to mobilfiksern.no/contactform.php this and retry.

    – Ved
    Jan 1 at 8:47











  • @ShireeshaParampalli what headers I should add?

    – Nadeem
    Jan 3 at 11:00











  • @Ved both of these are the same URLs, what url i should change?

    – Nadeem
    Jan 3 at 11:00














-1












-1








-1









This question already has an answer here:




  • How does Access-Control-Allow-Origin header work?

    13 answers



  • How to allow CORS?

    24 answers




I am not able to send email from my website (developed using HTML, CSS, JavaScript).



I get following error message when i send email:




Access to XMLHttpRequest at 'http://mobilfiksern.no/contactform.php' from origin 'http://www.mobilfiksern.no' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.




Can any one please help me to fix this issue?










share|improve this question

















This question already has an answer here:




  • How does Access-Control-Allow-Origin header work?

    13 answers



  • How to allow CORS?

    24 answers




I am not able to send email from my website (developed using HTML, CSS, JavaScript).



I get following error message when i send email:




Access to XMLHttpRequest at 'http://mobilfiksern.no/contactform.php' from origin 'http://www.mobilfiksern.no' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.




Can any one please help me to fix this issue?





This question already has an answer here:




  • How does Access-Control-Allow-Origin header work?

    13 answers



  • How to allow CORS?

    24 answers








javascript html css cors






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 1 at 10:06









Thelouras

5871720




5871720










asked Jan 1 at 8:39









NadeemNadeem

1




1




marked as duplicate by sideshowbarker cors
Users with the  cors badge can single-handedly close cors questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Jan 4 at 0:40


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.









marked as duplicate by sideshowbarker cors
Users with the  cors badge can single-handedly close cors questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Jan 4 at 0:40


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.















  • I guess the issue is because of www subdomain?

    – Priyank Panchal
    Jan 1 at 8:43











  • need to add headers

    – Shireesha Parampalli
    Jan 1 at 8:47











  • can you change your url from mobilfiksern.no/contactform.php to mobilfiksern.no/contactform.php this and retry.

    – Ved
    Jan 1 at 8:47











  • @ShireeshaParampalli what headers I should add?

    – Nadeem
    Jan 3 at 11:00











  • @Ved both of these are the same URLs, what url i should change?

    – Nadeem
    Jan 3 at 11:00



















  • I guess the issue is because of www subdomain?

    – Priyank Panchal
    Jan 1 at 8:43











  • need to add headers

    – Shireesha Parampalli
    Jan 1 at 8:47











  • can you change your url from mobilfiksern.no/contactform.php to mobilfiksern.no/contactform.php this and retry.

    – Ved
    Jan 1 at 8:47











  • @ShireeshaParampalli what headers I should add?

    – Nadeem
    Jan 3 at 11:00











  • @Ved both of these are the same URLs, what url i should change?

    – Nadeem
    Jan 3 at 11:00

















I guess the issue is because of www subdomain?

– Priyank Panchal
Jan 1 at 8:43





I guess the issue is because of www subdomain?

– Priyank Panchal
Jan 1 at 8:43













need to add headers

– Shireesha Parampalli
Jan 1 at 8:47





need to add headers

– Shireesha Parampalli
Jan 1 at 8:47













can you change your url from mobilfiksern.no/contactform.php to mobilfiksern.no/contactform.php this and retry.

– Ved
Jan 1 at 8:47





can you change your url from mobilfiksern.no/contactform.php to mobilfiksern.no/contactform.php this and retry.

– Ved
Jan 1 at 8:47













@ShireeshaParampalli what headers I should add?

– Nadeem
Jan 3 at 11:00





@ShireeshaParampalli what headers I should add?

– Nadeem
Jan 3 at 11:00













@Ved both of these are the same URLs, what url i should change?

– Nadeem
Jan 3 at 11:00





@Ved both of these are the same URLs, what url i should change?

– Nadeem
Jan 3 at 11:00












1 Answer
1






active

oldest

votes


















0














Every page top, or common top php file please add the following line.



<?php
//Session start section
?>
<?php

//Need to add the following codes
$origin = $_SERVER['HTTP_ORIGIN'];
// PHP 7.x version array
$allowed_domains = ['http://mobilfiksern.no','http://www.mobilfiksern.no'];
// PHP 5.x version array
//$allowed_domains = array("http://mobilfiksern.no", "http://www.mobilfiksern.no");

if (in_array($origin, $allowed_domains)) {
header('Access-Control-Allow-Origin: ' . $origin);
}
?>
<?php
//Usual codes
?>
<?php //Start the html tags ?>
<html>





share|improve this answer
























  • This is not working for me. Problem is in Ajex request. If I comment code with Ajex request then no error message but email is also not send then. with Ajex request there is error of CORS

    – Nadeem
    Jan 3 at 10:57


















1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














Every page top, or common top php file please add the following line.



<?php
//Session start section
?>
<?php

//Need to add the following codes
$origin = $_SERVER['HTTP_ORIGIN'];
// PHP 7.x version array
$allowed_domains = ['http://mobilfiksern.no','http://www.mobilfiksern.no'];
// PHP 5.x version array
//$allowed_domains = array("http://mobilfiksern.no", "http://www.mobilfiksern.no");

if (in_array($origin, $allowed_domains)) {
header('Access-Control-Allow-Origin: ' . $origin);
}
?>
<?php
//Usual codes
?>
<?php //Start the html tags ?>
<html>





share|improve this answer
























  • This is not working for me. Problem is in Ajex request. If I comment code with Ajex request then no error message but email is also not send then. with Ajex request there is error of CORS

    – Nadeem
    Jan 3 at 10:57
















0














Every page top, or common top php file please add the following line.



<?php
//Session start section
?>
<?php

//Need to add the following codes
$origin = $_SERVER['HTTP_ORIGIN'];
// PHP 7.x version array
$allowed_domains = ['http://mobilfiksern.no','http://www.mobilfiksern.no'];
// PHP 5.x version array
//$allowed_domains = array("http://mobilfiksern.no", "http://www.mobilfiksern.no");

if (in_array($origin, $allowed_domains)) {
header('Access-Control-Allow-Origin: ' . $origin);
}
?>
<?php
//Usual codes
?>
<?php //Start the html tags ?>
<html>





share|improve this answer
























  • This is not working for me. Problem is in Ajex request. If I comment code with Ajex request then no error message but email is also not send then. with Ajex request there is error of CORS

    – Nadeem
    Jan 3 at 10:57














0












0








0







Every page top, or common top php file please add the following line.



<?php
//Session start section
?>
<?php

//Need to add the following codes
$origin = $_SERVER['HTTP_ORIGIN'];
// PHP 7.x version array
$allowed_domains = ['http://mobilfiksern.no','http://www.mobilfiksern.no'];
// PHP 5.x version array
//$allowed_domains = array("http://mobilfiksern.no", "http://www.mobilfiksern.no");

if (in_array($origin, $allowed_domains)) {
header('Access-Control-Allow-Origin: ' . $origin);
}
?>
<?php
//Usual codes
?>
<?php //Start the html tags ?>
<html>





share|improve this answer













Every page top, or common top php file please add the following line.



<?php
//Session start section
?>
<?php

//Need to add the following codes
$origin = $_SERVER['HTTP_ORIGIN'];
// PHP 7.x version array
$allowed_domains = ['http://mobilfiksern.no','http://www.mobilfiksern.no'];
// PHP 5.x version array
//$allowed_domains = array("http://mobilfiksern.no", "http://www.mobilfiksern.no");

if (in_array($origin, $allowed_domains)) {
header('Access-Control-Allow-Origin: ' . $origin);
}
?>
<?php
//Usual codes
?>
<?php //Start the html tags ?>
<html>






share|improve this answer












share|improve this answer



share|improve this answer










answered Jan 1 at 9:11









Maths RkBalaMaths RkBala

1,90411116




1,90411116













  • This is not working for me. Problem is in Ajex request. If I comment code with Ajex request then no error message but email is also not send then. with Ajex request there is error of CORS

    – Nadeem
    Jan 3 at 10:57



















  • This is not working for me. Problem is in Ajex request. If I comment code with Ajex request then no error message but email is also not send then. with Ajex request there is error of CORS

    – Nadeem
    Jan 3 at 10:57

















This is not working for me. Problem is in Ajex request. If I comment code with Ajex request then no error message but email is also not send then. with Ajex request there is error of CORS

– Nadeem
Jan 3 at 10:57





This is not working for me. Problem is in Ajex request. If I comment code with Ajex request then no error message but email is also not send then. with Ajex request there is error of CORS

– Nadeem
Jan 3 at 10:57





Popular posts from this blog

MongoDB - Not Authorized To Execute Command

in spring boot 2.1 many test slices are not allowed anymore due to multiple @BootstrapWith

How to fix TextFormField cause rebuild widget in Flutter