Jump to content

Php form not sending to hotmail, gmail etc


Bakbak

Recommended Posts

I've got a simple form to email PHP system that works just fine for me, because my webmail comes from One and they support server side email scripts. But the problem is that Hotmail does not, so my form doesn't work for emails that don't support what One does support. I've looked through the internet to find the perfect solution, but PHP is not something that I like to use so playing around with it is not my cup of tea. Incase you wonder what my PHP mail folder currently looks like, have a look:

 

 

 

<?php

$name = $_POST['name'];

$lastname = $_POST['lastname'];

$email = $_POST['email'];

$phone = $_POST['phone'];

$workshop = $_POST['workshop'];

$location = $_POST['location'];

$information = $_POST['information'];

$contact = $_POST['contact'];

 

if( !isset($_POST['name'])) { die("No Direct Access"); }

 

$spam = $_POST['username'];

if($spam) { die("error: Spam");

 

} else {

 

}

 

$formcontent=" Naam: $name \n\n

Achternaam: $lastname \n\n

Email: $email \n\n

Telefoon: $phone \n\n

Workshop: $workshop \n\n

Locatie: $location \n\n

Contacten via: $contact \n\n

Extra informatie: $information";

$recipient = "Something@hotmail.com";

$subject = "Workshop klant";

$mailheader = "From: ".$_POST["email"]."\r\n"; mail($recipient, $subject, $formcontent, $mailheader) or die("Error!"); header('Location: verzonden.html');

 

As you can see, this is very basic stuff. That's why I came to the place where people know much much more about this than me.

 

Thanks for taking the time.

 

 

 

 

 

As you can see, this is very basic stuff. That's why I came to the place where people know much much more about this than me.

 

Thanks for taking the time

Link to comment
Share on other sites

First of all, you didn't tell us what errors (if any) you get. Without such a vital information, nobody will be able to help you further.

 

Second, I can't tell you enough how bad your code for mail sending is. Not only it has tons of "common sense" flaws, but it's also extremely insecure. In fact, using this code is like asking to hack you. Why don't you use an existing mailing solution like Swiftmail or similar?

Link to comment
Share on other sites

no matter how you end up interfacing php to the sending mail server, these emails are NOT being sent from the email address that someone entered in your form. DO NOT use that entered email address as the From: address.

 

if you use one of the suggested classes, phpmailer or swiftmailer, you can use SMTP (which is a protocol) to send the email to an email account that you 'own' (requires authenticating against the email account, with the mail box name/email address and the password.)

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.