php form, doesnt work with differents emails

It is for static page, dynamic page, website, SEO, performance and other web development discussion
ramverma
Posts: 435
Joined: Sat Aug 23, 2014 5:34 pm
Contact:

php form, doesnt work with differents emails

Postby ramverma » Sat Sep 12, 2015 9:43 am

Hello!

I have a confusing problem here.. I got this contact form which i coded very simple. And im wondering why it doesnt work when i use this email ="mortenkelum@live.com" but i works with a gmail and any other emails. Here is the code:

<?php

$firstname = $_POST ['firstname'];
$lastname = $_POST ['lastname'];
$emne = $_POST['emne'];
$email = $_POST ['email'];
$message = $_POST ['besked'];
$totalmessage = "
Fornavn: $firstname \n
Efternavn: $lastname \n
Email: $email \n
Tlf: $emne \n \n

Beskeden: $message \n";


$subject = "Ny besked fra NyTilgang kontaktform!";

mail("mortenkelum@live.com", $subject, $totalmessage, "From:" . $firstname . $lastname);

?>

I need help very fast! THanks


sidbhatt
Posts: 54
Joined: Sun Aug 30, 2015 8:01 am
Contact:

Re: php form, doesnt work with differents emails

Postby sidbhatt » Sun Oct 04, 2015 4:35 am

hi everyone,

For an email to be sent from a sending mail server (when using the mail() function, this is the mail server where your web site it hosted at) and accepted by a receiving mail server (where the to: address is hosted at), everything about the email must be correct and verifiable.

The From: mail header must be an email address and it's an email address where the email is being sent from. It's not anything to do with the information that a visitor entered in a form. It must either be an email address hosted at the sending mail server (the domain name in the from address must match and be traceable to the sending mail server's domain name) or you must have an SPF DNS record where the domain name is hosted at that indicate the sending mail server is authorized to send email for that domain name.

Since you are not supplying a valid email address at all in the From: mail header, either your sending mail server is supplying a default one that satisfies the live.com receiving mail server or the live.com receiving mail server isn't checking if the from address matches the sending mail server. In the case of trying to sent to other receiving mail servers, they are likely checking that the from address directly or indirectly matches the sending mail server.

It's also possible that your sending mail server has been black-listed (due to actual spam being sent through your sending mail server or by sending too many incorrectly formed emails) by the receiving mail servers where you cannot send to.

It's also possible that your sending mail server has relaying restrictions in place and it will send to an @live.com address, but not the others. If this is the case, the mail() function call should be returning a false value and you would be getting php error messages concerning relaying/authentication. Using a From: email address hosted at your sending mail server should satisfy relaying restrictions.


Return to “PHP, HTML, MYSQL and Web Hosting”

Who is online

Users browsing this forum: No registered users and 1 guest