2

It looks like everything goes right until I check my inbox and I don't see the email

PHP

$mail = $_POST['your_email'];    
$header = 'From: ' . $mail . " \r\n";
$header .= "X-Mailer: PHP/" . phpversion() . " \r\n";
$header .= "Mime-Version: 1.0 \r\n";
$header .= "Content-Type: text/plain";

$message = "$mail want to access the private beta";

$to = 'aca.spam@gmail.com';
$subject = 'Someone want to send a future message';

mail($to, $subject, utf8_decode($message), $header);

header("location:confirmation.html");
exit;

HTML

<form method="post" id="contact_form" name="contact_form" target="_self" lang="en" action="send.php">
     <div>
          <b>My email is</b> <input type="text" id="your_email" name="your_email" placeholder="email@ddress.com">
          <p>and I want access to the private beta.</p>
     </div>
     <button type="submit">YES!</button>
</form>

When I click on submit, go to the php file, and then return to confirmation.html. Everything looks right, but I don't receive any email.

Jason D
  • 8,023
  • 10
  • 33
  • 39
  • 2
    You cannot send the `From` field to a domain that you are not sending from and are not authenticated to send from. Otherwise, I could spoof your address and email everyone in the world pretending to be Sebastian Suarez. – Ohgodwhy Aug 04 '15 at 23:06
  • possible duplicate of [PHP mail form doesn't complete sending e-mail](http://stackoverflow.com/q/24644436) – mario Aug 04 '15 at 23:36
  • possible duplicate of [PHP mail form doesn't complete sending e-mail](http://stackoverflow.com/questions/24644436/php-mail-form-doesnt-complete-sending-e-mail) – andrewsi Aug 05 '15 at 00:22

1 Answers1

1

As @ohgodwhy pointed out, you need to be properly authenticated in order to send an email from a domain that is not the same as your website.

Check out this other post which gave an example of authenticating with Google SMTP server.

Community
  • 1
  • 1
Mike G
  • 668
  • 1
  • 6
  • 17
  • Thanks Michael! But that code is to send an email form one mail, to another is like a forward, right? So, you say if my page is www.something.com and my email is me@something.com is work correctly? – Sebastian Suarez Aug 05 '15 at 19:41
  • That code sends an email from one address to another address. It would appear to the recipient as if the from address had sent it normally. Correct, if you have an email address at the same domain as the website domain it should work correctly. In either case I recommend using the code from the linked answer. – Mike G Aug 05 '15 at 19:46
  • Ok, great Michael. Thank you! You Rock! – Sebastian Suarez Aug 05 '15 at 19:52