0
votes
<?php
   SendEmail("[email protected]","Dima", "trololo");
   function SendEmail($to,$user_name, $user_password)
   {

     $subject="Political forum: registration";
     $body = 'Your user name is: ".$user_name  <br/>'.$user_name.' Your password is: '.$user_password.'<br/><br/> Click the link below for validation: <a href="#">Validation_Link</a>';

     $headers="FROM: $to\r\n";
     $headers.=" Content=type: text/html\r\n";


   if (mail($to, $subject, $body, $headers)) {
       echo("<p>Message successfully sent!</p>");
      } else {
       echo("<p>Message delivery failed...</p>");
      }
   }

?>

The above fails!!!

I had a little read and I found that you need to change this inyour php.ini:

; For Win32 only. ; http://php.net/smtp SMTP = localhost ; http://php.net/smtp-port smtp_port = 25

; For Win32 only. ; http://php.net/sendmail-from sendmail_from = [email protected]

I did, but it still fails

Message:

Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\xampp\htdocs\PoliticalForum\StoredProcedure\User\email.php on line 16

Message delivery failed...

1
"Fails" means what? Any error messages? - Ocaso Protal
Do you get any error messages? If it is a silent error, try to var_dump error_get_last() after executing mail() - pdu
sorry forgot to add...added above - Matrix001
Do you have an SMTP server set up on your machine? - jprofitt
well, I am not sure what it is... - Matrix001

1 Answers

1
votes

a small thing.. the text you sent doesn't look fine.. but I guess that you will fix that if you get it to work..

about why it doesn't work: you seem to try to send to an yahoo address.. a lot of servers refuse mails that come from the same address (especially that you are sending from your own server, and not yahoo)

so instead of using the user's email address as sender pick another one so you need to change this line:

$headers="FROM: $to\r\n";

and use some other thing than $to