0

I have set up the Sendmail client on my localhost xammp server running on my home pc but I am getting the following error:xx-xx-xx xx:xx:xx: Message is missing sender's address. I have gotten it to work when I use the hard code what I want to send, like so:

$msg = "hello world";

mail("example@gmail.com","My subject",$msg, 'From: admin@myEmailClient.com');

but when I try and implement my login validation script It does not work and I get the aforementioned error.

emailvalidation.php

        $to = $email;
        $sub = 'email verification';
        $msg = "<a href='http://localhost/verify.php?vkey=$vkey'>account verification </a>";
        $headers = "From: admin@myEmailClient.com \r\n";
        $headers = "MIME-Version: 1.0". '\r\n';
        $headers = "Content-type:text/html;charset=UTF-8 ". '\r\n';


        mail($to, $sub, $msg, $headers);

my email variable is set by the user if that helps, I don't think its a problem with the items being parsed because when I check my database all rows are properly filled in.

thank you for your time

edit

I think it's a problem with the r\n parts, these are the parts that enable HTML in emails. when I get rid of them it works

m.seigmiller
  • 90
  • 11

1 Answers1

0

I'm not sure if I should delete this question because of the speed I was able to solve it but I hope this helps someone who had the same problem as I did.

here is how I solved the problem

        $message = "<a href='http://localhost/verify.php?vkey=$vkey'>account verification </a>";

        $to = $email;
        $subject = 'account validation';
        $from = 'admin@myEmailClient.com';
 
        $headers  = 'MIME-Version: 1.0' . "\r\n";
        $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
 
        $headers .= 'From: '.$from."\r\n".
        'Reply-To: '.$from."\r\n" .
        'X-Mailer: PHP/' . phpversion();

        if(mail($to, $subject, $message, $headers)){
            echo 'Your mail has been sent successfully.';
        } else{
            header("location: index.PHP");
        }

I got the solution from here. tutorial republic

m.seigmiller
  • 90
  • 11