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.

$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.

8 Years
Discussion Span
Last Post by rajarajan2017

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)

// i just googled these
// if you need authorization
$to = "someone@example.com";
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = "someonelse@example.com";
$headers = "From: $from";
echo "Mail Sent.";

I hope this helps out.


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

Edited by rajarajan2017: n/a


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.


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.


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";
//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' />


that's for email.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?

Edited by charvie: n/a


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

Edited by charvie: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.