Sending email using PHP......

Ok....
1st time on PHP today , self learning....managed to configure PHP - do the various settings on IIS and also have PHP read and write to a sample DB on MYSQL......

So at the end of the day , I have managed to read a particular column data and also write to a specific column data....

Now what I am interested in knowing / learning is : How can I have PHP - "mail" me the contents of the user form.....

for example....the php page which i created....opens a page with a txt box...on clicking submit it writes the data to mysql db.....

now what I want to do is have the inputed text 'emailed' to a particular email address...(along with the data going into the DB ).....can it be done ?

or has it to go only to 1 , i.e either the db or either the mail....

looking forward for some help here regarding this.....please post examples with codes and how to go abt it if possible.....

thanks in advance for the assistance.
 
Stolen from the Mail manual, shamelessly :p

<?php

// 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('caffinated@example.com', 'My Subject', $message);

?>

You'll need to configure the email server like described below.

PHP: Runtime Configuration - Manual
 
viridian said:
Stolen from the Mail manual, shamelessly :p

<?php
// 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('caffinated@example.com', 'My Subject', $message);
?>

You'll need to configure the email server like described below.
PHP: Runtime Configuration - Manual

As of now im stuck on 2 error messages....
SMTP server response: 554 5.7.1 <xyz@abc.com>: Recipient address rejected: Access denied
and

Fatal error: Class 'Mail' not found

trying to figure that out...i guess i need to pass the authentication password along with the script as my smtp server needs authentication for outgoing mails......

@viridian : nothing shamless in what u did , its out there for our reference and usuage :) thanks.
 
Now , I have tried 2-3 different scripts and all of them give me the same error....

Warning: mail() [function.mail]: SMTP server response: 554 5.7.1 <xyz@xyz.com>: Recipient address rejected:

im using remote smtp autentication itself.....
 
^^ i guess thats the issue....

I DO not have a local SMTP server on my PC and I am trying to send external emails to .gmail.com and .yahoo.com domains........and thats why I'm guessing im getting the error messages.

Correct me if I'm wrong , I would need to have the needfull files placed on a configured SMTP server.......
 
Back
Top