Re: php question
by Kevin Waterson <kevin(at)oceania.net>
|
Date: |
Mon, 27 Jan 2003 11:08:16 +1100 |
To: |
hwg-techniques(at)mail.hwg.org |
References: |
earthlink laptop1 earthlink2 |
|
todo: View
Thread,
Original
|
|
This one time, at band camp,
terry goode <tgoode(at)earthlink.net> wrote:
> ok here is the simple code
> <?php
> //first_mail.php
> $mail_to ="tgoode(at)earthlink.net";
> $mail_subject = "testing php mail";
> $mail_body = "testing php mail.\r\n";
> // first line of text with a cf & lf//
> $mail_body = "testing if it gets out and back in.\n";
> // second line of text with a cf & lf//
> if(mail($mail_to, $mail_subject, $mail_body))
> echo "successfully sent the e-mail \"$mail_subject\" to $mail_to.";
> else echo "failed to send the e-mail \"$mail_subject\"."
> ?>
If you are viewing the $mail_body with a browser, the \n will be ignored.
If you wish view the result in a browser, you will will need to use nl2br()
If you are simply sending a mail, try this...
<?php
// set the send to address
$email_to = 'tgoode(at)earthlink.net';
// set the from address
$email_from ='bill(at)ms.com';
// set the subject
$subject = 'Testing';
// create the body of the mail
$mail_body = 'This is a line of text'."\n";
$mail_body .= 'This is a second line of text';
// send the mail
if(!mail("$email_to",$subject,$mail_body, "From: $email_from\nReply-To: $email_from\nX-Mailer: PHP/" . phpversion()))
{
// print an error
echo 'Unable to send mail.'
}
else
{
// give praise to the php gods
echo 'Mail successfully sent.<br />';
echo 'Message body will look like this<br />';
echo nl2br($mail_body);
}
?>
hope this helps
Kevin
--
______
(_____ \
_____) ) ____ ____ ____ ____
| ____/ / _ ) / _ | / ___) / _ )
| | ( (/ / ( ( | |( (___ ( (/ /
|_| \____) \_||_| \____) \____)
Kevin Waterson
Port Macquarie, Australia
HWG hwg-techniques mailing list archives,
maintained by Webmasters @ IWA