By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,882 Members | 2,460 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,882 IT Pros & Developers. It's quick & easy.

sending form data as email using SMTP server ???

P: n/a
How can I take my form data and send it as an email using my SMTP server
located @ my ISP using PHP ?

my form has several fields:

TO: this is a drop down list

FROM: this is a drop down list

SUBJECT: Free Type

MESSAGE: Free Type

CC: Check Box

what I need to do is send the email TO the user selected, FROM the user
selected, with the Subject and Message, If ticked CC then copied to the
FROM user !

Any Ideas ?

Thanks
Jul 16 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
php.net - search for the email functions.

"James" <Ja***@NotHere.com> wrote in message
news:cd********************************@4ax.com...
How can I take my form data and send it as an email using my SMTP server
located @ my ISP using PHP ?

my form has several fields:

TO: this is a drop down list

FROM: this is a drop down list

SUBJECT: Free Type

MESSAGE: Free Type

CC: Check Box

what I need to do is send the email TO the user selected, FROM the user
selected, with the Subject and Message, If ticked CC then copied to the
FROM user !

Any Ideas ?

Thanks

Jul 16 '05 #2

P: n/a
although i don't think there's a CC function - just use the from: as an
additional to: if it's checked, which should work.
"Matt Montgomery" <NO********@NOSPAMchums.com> wrote in message
news:sW*****************@news.uswest.net...
php.net - search for the email functions.

"James" <Ja***@NotHere.com> wrote in message
news:cd********************************@4ax.com...
How can I take my form data and send it as an email using my SMTP server
located @ my ISP using PHP ?

my form has several fields:

TO: this is a drop down list

FROM: this is a drop down list

SUBJECT: Free Type

MESSAGE: Free Type

CC: Check Box

what I need to do is send the email TO the user selected, FROM the user
selected, with the Subject and Message, If ticked CC then copied to the
FROM user !

Any Ideas ?

Thanks


Jul 16 '05 #3

P: n/a
James <Ja***@NotHere.com> wrote in message
news:<cd********************************@4ax.com>. ..

How can I take my form data and send it as an email using my SMTP server
located @ my ISP using PHP ?

my form has several fields:

TO: this is a drop down list
FROM: this is a drop down list
SUBJECT: Free Type
MESSAGE: Free Type
CC: Check Box

what I need to do is send the email TO the user selected, FROM the user
selected, with the Subject and Message, If ticked CC then copied to the
FROM user !

Any Ideas ?


Actually, two. :)

1. If your ISP allows you to use the mail() function and has it
properly configured:

if ($_POST) {
$to = $_POST['TO'];
$from = $_POST['FROM'];
$subject = $_POST['SUBJECT'];
$message = $_POST['MESSAGE'];
} else {
die ('What the heck am I supposed to mail?');
}
$headers = 'From: ' . $from . "\r\n";
if ($_POST['CC']) {
$headers .= 'Cc: ' . $from . "\r\n";
}
mail ($to, $subject, $message, $headers);

2. If not, get yourself a copy of phpMailer (http://phpmailer.sf.net/)
and send your message via an external SMTP server:

require ('class.phpmailer.php');
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Host = 'smtp.mysite.com';
$mail->SMTPAuth = true; // These three lines are necessary
$mail->Username = 'me'; // only if your SMTP server
$mail->Password = 'my_password'; // requires authentication
$mail->From = $_POST['FROM'];
if ($_POST['CC']) {
$mail->AddCC($_POST['FROM']);
}
$mail->Subject = $_POST['SUBJECT'];
$mail->IsHTML(false);
$mail->Body = $_POST['MESSAGE'];
$mail->Send();

Cheers,
NC
Jul 16 '05 #4

P: n/a
try using mail() function. (http://es.php.net/manual/en/function.mail.php)
Jul 17 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.