Jump to content

Need help using the mail function


eldan88

Recommended Posts

Hey,

 

 I am learning on how to use the mail function in PHP and have wrote one in PHP. Every time I try to execute it, I get an the message that says error. I have scanned through my code and everything seems to correct. Do you guys have any suggestions? Thanks

<?php

	$to = "nobody@somedomain.com";

	$subject = "Mail Test at ".strftime("%T", time());

	$message = "This is a test.";
	// Optional: Wrap lines for old email programs
	// wrap at 70/72/75/78
	$message = wordwrap($message,70);
	
	$from = "somebody@somedomain.com";
	$headers = "From: {$from}";
	
	$result = mail($to, $subject, $message, $headers);
	echo $result ? 'Sent' : 'Error'; // I get an "Error" every time I run this page
  
?>
Link to comment
Share on other sites

Are you running this script locally? If so, do you have a mail server setup so that the mail is actually sent?

 

Also you could add this to the top to get descriptive errors:

ini_set('display_errors','on');
error_reporting(E_ALL);
Link to comment
Share on other sites

 

Are you running this script locally? If so, do you have a mail server setup so that the mail is actually sent?

 

Also you could add this to the top to get descriptive errors:

ini_set('display_errors','on');
error_reporting(E_ALL);

 

 

 

Are you running this script locally? If so, do you have a mail server setup so that the mail is actually sent?

 

Also you could add this to the top to get descriptive errors:

ini_set('display_errors','on');
error_reporting(E_ALL);

Hey,

 

 I am using a mac, and figured that I have a send mail application installed as a mail server. I am trying to send this locally. 

 

Will it work if I install PHP mailer??

 

Sorry I am really new to this!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

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.