These are the steps in registering a new user.

1. A new user is registered (provide name, address, email etc.)
2. An email is sent to the email he/she provided, which contains his login information.

the problem now is the emial code. I've never done this before so I don't know how this works. I tried searching for help, and the acronym SMTP always pops up. and I don't know how that works either. I know I have to configure php.ini to be able to do this, but I don't know what to change.

here's a sample code i got from the net. I'm trying to make this work first.

<?php
$email_to = "my_email@yahoo.com";
$email_subject = "Test E-Mail (This is the subject of the E-Mail)";
$email_body = "This is the body of the Email \nThis is a second line in the body!";

if(mail($email_to, $email_subject, $email_body)){
echo "The email($email_subject) was successfully sent.";
} else {
echo "The email($email_subject) was NOT sent.";
}
?>

Please Help me.

Hi,
First off, a really good tutorial website would be www.w3schools.com. They have alot of different things you can learn. Thats where i got my email code. Most mail servers require a SMPT in order to find it, its like have a website but with no DNS lookup.
So a real simple one to start would be (from www.w3schools.com)

<?php
// i just googled these
ini_set("SMTP","pop3.mail.yahoo.com");
ini_set("smpt_port","995");
// if you need authorization
ini_set("smtp_username","username");
ini_set("smtp_password","password");
$to = "someone@example.com";
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = "someonelse@example.com";
$headers = "From: $from";
mail($to,$subject,$message,$headers);
echo "Mail Sent.";
?>

I hope this helps out.

I have just changed this part of php.ini and it works for me.
Check it out.

[mail function]
; For Win32 only.
SMTP = mail.mywebsite.com // smtp mail server name
smtp_port = 25

Member Avatar for rajarajan2017

Yeah, the only changes we need in php.ini, but for different scenarios the thing is also different.

Thank you for your help but this error is generated when i changed my SMTP.

Warning: mail() [function.mail]: Failed to connect to mailserver at "mail.yahoo.com" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set()


i don't know if i'm assigning the right data to the SMTP. where can i find the correct data to assign to it?

I need to know the right SMTP value so i can continue with the tutorial from w3 and from the article you gave. Thank you.

Member Avatar for rajarajan2017

You are the right place now. You script will work if you tested on you server by loading your files in ftp.

so it's not working coz it's running in localhost?

our site is down at the moment. I'll try to test it when it's up and running again.

[mail function]
; For Win32 only.
SMTP = mail.yahoo.com
smtp_port = 25

; For Win32 only.
;sendmail_from =

is that the correct thing to do in the php.ini? i mean is the SMTP value correct already?

and here's the code i got from the net.

<html>
<body>

<?php
if (isset($_REQUEST['email']))
//if "email" is filled out, send email
  {
  //send email
  $email = $_REQUEST['email'] ;
  $subject = $_REQUEST['subject'] ;
  $message = $_REQUEST['message'] ;
  mail( "someone@example.com", "Subject: $subject",
  $message, "From: $email" );
  echo "Thank you for using our mail form";
  }
else
//if "email" is not filled out, display the form
  {
  echo "<form method='post' action='mailform.php'>
  Email: <input name='email' type='text' /><br />
  Subject: <input name='subject' type='text' /><br />
  Message:<br />
  <textarea name='message' rows='15' cols='40'>
  </textarea><br />
  <input type='submit' />
  </form>";
  }
?>

</body>
</html>

that's for email.php

<?php
  $email = $_POST['email'] ;
  $subject = $_POST['subject'] ;
  $message = $_POST['message'] ;
  mail( "someone@example.com", "Subject: $subject", $message, "From: $email" );
  echo "Thank you!";
?>

and that's for mailform.php

do you think these codes will be alright when uploaded to the net?

Member Avatar for rajarajan2017

Yahoo Outgoing Mail Server (SMTP) - smtp.mail.yahoo.com (port 25)

i already change it to that. now i'll just wait if it'll work. i hope it works T.T

Thank you :) I hope you'll still help me when if i get errors by the time i upload this

Member Avatar for rajarajan2017

Sure.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.