...

View Full Version : php



Larryzx
10-15-2009, 05:00 PM
I am new to php, firstly what does php mean, secondly and more seriously I would like to know how to send a attachment as part of a mail using the mail function..

I copied the following code off the net it works but I dont know how to make it work to send an attachment to.

<?php
//define the receiver of the email
$to ="lawwz@hotmail.com";
// define the subject
$subject = "Testing mail function";
// define the message to be send each line should be separated with a \n
$message ="Hello there how are you\nfine thanks ";
//define the headers we want passed. Note they are separated with \r\n
$headers ="From: lawwz@hotmail.com\n";
$headers .="Reply-To: lawwz@hotmail.com";
//send the mail
$mail_sent = @mail[/B]($to, $subject, $message, $headers);
echo $mail_sent ? "Mail sent" : "Mail failed";
?>


Also I get a waring with this code but if I change the last line to @mail instead of mail(...) it doesnt give the warning?

Fumigator
10-15-2009, 05:21 PM
The acronym PHP is recursive.. it stands for PHP Hypertext Preprocessor. Clever I know.

Anyways you should take a look at the manual, it has a nice little introduction to PHP and how it works. In the left column the question "What is PHP?" is asked and answered.

http://www.php.net

The "@" sign suppresses warnings and errors. It doesn't do anything to fix what's actually wrong, and makes it extremely difficult to troubleshoot and debug problems. It's a horrible way to "fix" crappy code. The _only_ reason to use it is if you are a terrible programmer who doesn't know how to code. :D

Sending attachments using the mail() function can be surprisingly challenging. It's definitely not a "beginner" task, but if you Google +php +email +attachment you'll find several tutorials on the subject.

My personal favorite way of doing it is by using a third-party open source package called PHP Mailer. Makes it pretty simple.

http://phpmailer.worxware.com/



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum