469,328 Members | 1,327 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,328 developers. It's quick & easy.

sending form data as email using SMTP server ???

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
4 15251
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
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
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
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.

Similar topics

15 posts views Thread by Sven Templin | last post: by
3 posts views Thread by Jared | last post: by
13 posts views Thread by joe215 | last post: by
1 post views Thread by mark | last post: by
6 posts views Thread by Anuradha | last post: by
31 posts views Thread by happyse27 | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by Purva khokhar | last post: by
reply views Thread by haryvincent176 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.