As I don't know what script you tried, try this: <?php $to = 'recipient@example.com'; // change this to the recipient's email address $subject = 'This is the subject of your email'; $message = 'This is the message'; $from = 'From: Sample Sender <sender@example.com>'; // change this to the sender's name and email address if ( mail($to, $subject, $message, $from) ) { echo "Email has been successfully sent by mail() function.<br />\n"; } else { echo "Oops, it seems something went wrong...<br />\n"; } ?> PHP:
The code Bogi provided is not working always. If you will have problems, try to use PHPMailer library - it is simple and there is a lot of documentation, sample scripts that will help you.
The simple way to send email via php : mail ($to_email , $subject , $message , $additional_headers); PHP:
It gave me this message Network Error (dns_unresolved_hostname) Your requested host "google.aramcoservices.com" could not be resolved by DNS. For assistance, contact your network support team.
try this one... its perfectly working code $subject = 'the subject'; $message = 'hello'; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= 'From: DealsToDO '.$fromAdd.''. "\r\n"; $mail = @mail($toAdd, $subject, $message, $headers); echo $mail . if you get output 1 then mail sent is success else null means their is some error in server or html template.. this script is for both text as well as html template mail like Newsletters...
I tried with a new host .Now ,it give me this messageObject not found!The requested URL was not found on this server. If you entered the URL manually please check your spelling and try again. If you think this is a server error, please contact the webmaster. Error 404localhost8/8/2011 10:45:56 AMApache/2.2.17 (Win32) mod_ssl/2.2.17 OpenSSL/0.9.8o PHP/5.3.4 mod_perl/2.0.4 Perl/v5.10.1
It's just a simple 404 error message, meaning the URL you entered wasn't found. Make sure the URL you typed is correct - check the spelling, CApItalIZAtion etc
When you say you're using xampp, I'm assuming your using your home PC as the server. The PHP mail() function never worked for me on xampp cuz there are a lot of technical configurations that must be done. Most, if not all shared hosting providers, the code provided above will work.
<?php $to = "someone@example.com"; $subject = "Test mail"; $message = "Hello! This is a simple email message."; $from = "someonelse@example.com"; $headers = "From:" . $from; mail($to,$subject,$message,$headers); echo "Mail Sent."; ?> PHP: Also, here's a simple script using a form setup: <html> <body> <?php if (isset($_REQUEST['email'])) //if "email" is filled out, send email { //send email $email = $_REQUEST['email'] ; $subject = $_REQUEST['subject'] ; $message = $_REQUEST['message'] ; mail("someone@example.com", "$subject", $message, "From:" . $email); echo "Thank you for using our mail form"; } else //if "email" is not filled out, display the form { echo "<form method='post' action='mailform.php'> Email: <input name='email' type='text' /><br /> Subject: <input name='subject' type='text' /><br /> Message:<br /> <textarea name='message' rows='15' cols='40'> </textarea><br /> <input type='submit' /> </form>"; } ?> </body> </html> PHP:
I think the problem ,there's some configurion for xampp to send email, but the problem as I mentioned befor I'm in this language.So,if someone knows how configure xampp,post plz?
hi, from xampp localhost server you cannot send mail, you should configure SMTP port in xampp server to send an email from local system. This link will help you http://www.apachefriends.org/f/viewtopic.php?t=21045