Question:
hello.. anyone know how to send data to email by using php ? i m using xampp?
NurulNajmi
2009-03-04 20:08:27 UTC
i make a system for registration . the flow is like this :

1. user will insert all their data in the form.. then when they click submit it will send a link to user and admin..

At user , it will send msg to inform them to wait approval from admin before they can login

At admin , it will send notification about have new user want to register. and also has a link to admin click for approval.

2. Admin will approve or reject the new register .

3. The result weather admin approve or reject will send back to user

4. if approve , it will send to user email the link to login and with user name and password.

home anyone can help me.. or anyone have sample coding ? with that i can refer to the coding.. thank you..... i m waiting for anyone reply..
Three answers:
anonymous
2009-03-05 00:29:03 UTC
Hm....



















(PHP 3, PHP 4, PHP 5)

mail -- Send mail

Description

bool mail ( string to, string subject, string message [, string additional_headers [, string additional_parameters]] )



Sends an email.

Parameters

to : Receiver, or receivers of the mail.

The formatting of this string must comply with RFC 2822. Some examples are:

user@example.com

user@example.com, anotheruser@example.com

User

User , Another User



subject

Subject of the email to be sent.

message

Message to be sent.

Each line should be separated with a LF (\n). Lines should not be larger than 70 characters.



additional_headers (optional)

String to be inserted at the end of the email header.



This is typically used to add extra headers (From, Cc, and Bcc). Multiple extra headers should be separated with a CRLF (\r\n).



????: When sending mail, the mail must contain a From header. This can be set with the additional_headers parameter, or a default can be set in php.ini.



Failing to do this will result in an error message similar to Warning: mail(): "sendmail_from" not set in php.ini or custom "From:" header missing.



????: If messages are not received, try using a LF (\n) only. Some poor quality Unix mail transfer agents replace LF by CRLF automatically (which leads to doubling CR if CRLF is used). This should be a last resort, as it does not comply with RFC 2822.



additional_parameters (optional)

The additional_parameters parameter can be used to pass an additional parameter to the program configured to use when sending mail using the sendmail_path configuration setting. For example, this can be used to set the envelope sender address when using sendmail with the -f sendmail option.

The user that the webserver runs as should be added as a trusted user to the sendmail configuration to prevent a 'X-Warning' header from being added to the message when the envelope sender (-f) is set using this method. For sendmail users, this file is /etc/mail/trusted-users.



Returns TRUE if the mail was successfully accepted for delivery, FALSE otherwise.

It is important to note that just because the mail was accepted for delivery, it does NOT mean the mail will actually reach the intended destination.



Ex:


// The message

$message = "Line 1\nLine 2\nLine 3";

// In case any of our lines are larger than 70 characters, we should use wordwrap()

$message = wordwrap($message, 70);

// Send

mail('maymail@example.com', 'My Subject', $message);

?>



The addition of basic headers, telling the MUA the From and Reply-To addresses:


$to = 'nobody@example.com';

$subject = 'the subject';

$message = 'hello';

$headers = 'From: webmaster@example.com' . "\r\n" .

'Reply-To: webmaster@example.com' . "\r\n" .

'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $headers);

?>
devona
2016-05-25 04:37:31 UTC
You cannot send mail using mailer script on xxamp...u must have an online host or server of your own to do so.....there are many free webhosting sites google them...errors regarding authentication and ports are just because you are on a localhost not on global one.
?
2009-03-04 23:49:03 UTC
go to www.web2coders.com. Scroll down. Click on "login script" and download the zip file. Follow instructions. You have a log-in system.

For the email:

HTML FORM to EMAIL (Php)



Your index.html file:













Your name:


Your password:


Your email:












Your emailfwd.php file:












$name = $_POST['name'];

$pwd = $_POST['pwd'];

$email = $_POST['email'];

$to = "youremail@whatever.com";

$headers = "From: ".$email. "\r\n";

$subject = "Submitted application";

$msg = $name . " has sumitted a form!\r\n";

$msg .= "Pwd: " . $pwd . "\r\n";

$msg .= "email address: " . $email . "\r\n";

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

echo ("Mail processed.");

?>







Combine the two, and you are nearly there!


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...