Need help

Posts 1–3 of 3 · Page 1 of 1
Need help
Code:
<?php

if (isset($_POST['submit'])) {
    $name = $_POST['name'];
    $email = $_POST['email'];
    $message = $_POST['message'];
    
    $mailTo = "MYMAIL@hotmail.com";
    $headers = "From: ".$email;
    $txt = "You have received an e-mail from ".$email.".\n\n".$name."\n\n".message;
    
    mail($mailTo, $name, $txt);
    header("Location: mailsend.php");
}


How can I make this email to appear on the top instead of my servers email address?
The $headers doesnt seem to work?

whenever I change the code to mail($mailTo, $name, $txt, $headers); I do not receive any email at all.
Quote Originally Posted by dawid17 View Post
Code:
<?php

if (isset($_POST['submit'])) {
    $name = $_POST['name'];
    $email = $_POST['email'];
    $message = $_POST['message'];
    
    $mailTo = "MYMAIL@hotmail.com";
    $headers = "From: ".$email;
    $txt = "You have received an e-mail from ".$email.".\n\n".$name."\n\n".message;
    
    mail($mailTo, $name, $txt);
    header("Location: mailsend.php");
}


How can I make this email to appear on the top instead of my servers email address?
The $headers doesnt seem to work?

whenever I change the code to mail($mailTo, $name, $txt, $headers); I do not receive any email at all.
Mail does have a 5th parameter that you can add. I think you can force the mail from address, like I have done below. But, it possibly could be how your mail server is setup that is causing the issue. You can also pass an array to the 4th parameter btw.

Code:
<?php

if (isset($_POST['submit'])) {
    $name = $_POST['name'];
    $email = $_POST['email'];
    $message = $_POST['message'];
    
    $mailTo = "MYMAIL@hotmail.com";
    $headers = array(
        'From' => $email,
        'Reply-To' => $email
    );
    $params = "-f ".$email;
    $txt = "You have received an e-mail from ".$email.".\n\n".$name."\n\n".message;
    
    mail($mailTo, $name, $txt, $headers, $params);
    header("Location: mailsend.php");
}
Quote Originally Posted by Develon View Post
Mail does have a 5th parameter that you can add. I think you can force the mail from address, like I have done below. But, it possibly could be how your mail server is setup that is causing the issue. You can also pass an array to the 4th parameter btw.

Code:
<?php

if (isset($_POST['submit'])) {
    $name = $_POST['name'];
    $email = $_POST['email'];
    $message = $_POST['message'];
    
    $mailTo = "MYMAIL@hotmail.com";
    $headers = array(
        'From' => $email,
        'Reply-To' => $email
    );
    $params = "-f ".$email;
    $txt = "You have received an e-mail from ".$email.".\n\n".$name."\n\n".message;
    
    mail($mailTo, $name, $txt, $headers, $params);
    header("Location: mailsend.php");
}
This is a bad idea, and you will be marked as spam instantly. If you want to send an email from your gmail account, send email through googles SMTP server. I think I got a simple SMTP script somewhere on my HDD that i made ages ago.

here - https://pastebin.com/38WWSYv3

You may need to fix encoding stuff, but that shouldn't be hard.


- - - Updated - - -

nevermind that was my raw mail object parser...

use this - https://pastebin.com/6mPfQL8y
Posts 1–3 of 3 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Need help?