Hi, i want to create a PHP script that will use mail function. Do i need to install any addition packages for mail function? Can someone guide me, pls? Thanks in advance
From http://www.php.net/manual/en/ref.mail.php: For an example of actual usage of mail(), see http://www.php.net/function.mail
Hi... Thanks for the replies Really appreciate them. I got this error : Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\321_Test\site\download_viewer_check.php on line 9 Below is a piece of code that i copied from manual. <?php $to = 'aileen_p@yahoo.com'; $subject = 'CSCI321t; $message = 'hello. testing email'; $headers = 'From: webmaster@example.com' . "\r\n" . 'Reply-To: webmaster@example.com' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); mail($to, $subject, $message, $headers); ?> Code (markup): Any ideas why is this happening? Thanks...
You need to have an SMTP server running on the computer for mail to be sent. If you are only getting this error when testing on your own computer then its not a huge error, to test out the mail sending you should upload the script to a webserver, even a free one will do, and run it from there. If you are running Windows XP pro you can install IIS which has an SMTP server built into it. I'm sure others may also be able to recommend other SMTP server software that can do the trick.
Well, we have a SMTP server installed at our server. I've upload my files there.. We're using Apache for our webserver
All should work well then, as I said if you want to test on your own PC you can do so, but its only for a bit of convenience.
Yes, it can work now after resetting my SMTP server Thanks for your replies Btw, can i ask you something again? Does mail function support attachment of files? I read some articles about PHPMailer class, if i want to attach a file to my email, do i need to use this class?
I would suggest you use a pre-build class to attach a file to a email. Makes life easier and you don't have to learn how to do it all by yourself. phpclasses.org has a bunch of them for you to try out. Also, since you were asking. The error code you shown to us said everything you should have needed to know. Verify your "SMTP" settings in php.ini. as it looks like you corrected.
Hi, exodus. I try to use PHPMailer class. But when i try to send an email to my account, i never receive the email. Though the code doesn't result any error messages. Below is my code : <?php require("class.phpmailer.php"); $mail = new PHPMailer(); $mail->IsMail(); $mail->AddAddress("cemplukcute2003@yahoo.com","Aileen Pranoto"); $mail->WordWrap = 50; // set word wrap $mail->AddAttachment("./license/license.zip"); // attachment $mail->IsHTML(true); // send as HTML $mail->Subject = "Sig-Share is being tired"; $mail->Body = "This is the <b>HTML body</b>"; $mail->AltBody = "This is the text-only body"; if(!$mail->Send()) { echo "Message was not sent <p>"; echo "Mailer Error: " . $mail->ErrorInfo; exit; } else { echo "Message has been sent"; } ?> Code (markup): Can you help me, pls? Thanks
Check this out.. Rather old, but still works for me. http://www.codewalkers.com/c/a/Email-Code/PHP-Text-HTML-Email-with-Attachments-21/