Jump to content
xisto Community
contactskn

Sending Email Problem In Php please help me.

Recommended Posts

Hello friends first of all a happy christmas to you all there. I have coded in php somewhat similar code shown below but it is showing error that is echoing "The email($email_subject) was NOT sent." I am not able to understand why it is happening. Am I wrong with my code or some other problem please help me out dear friends. 

<?php$email_to = "somebody@email.com";$email_subject = "Test E-Mail (This is the subject of the E-Mail)";$email_body = "This is the body of the Email \nThis is a second line in the body!";if(mail($email_to, $email_subject, $email_body)){    echo "The email($email_subject) was successfully sent.";} else {    echo "The email($email_subject) was NOT sent.";}?>
Notice from truefusion:
Place all code within CODE or CODEBOX bbcode. Thanks.

Share this post


Link to post
Share on other sites

Is the code just similar, or exactly the same? The script you have posted should work, though it might be a good idea to add some headers to the e-mail (refer to the PHP mail() page). There is a slight chance that you don't have the modules required for sending mail, so it would be useful to know where you are testing the script.

Share this post


Link to post
Share on other sites

Where are you testing this at? On a local server or remote? If on a local server, bear in mind that PHP cannot send mail on its own and requires a MTA that supports SMTP, like postfix or other, to be installed on the server and configured properly. If on a remote server, then you may want to contact the administrator to see if the PHP mail function has not been disabled, etc.

Share this post


Link to post
Share on other sites

In my experience, some Servers require a From Header to be included in emails sent via php.I believe this is an anti-spam requirement from the Server Admins, and assumes as noted above that the server allows php mail functionality.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.