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 = "[email protected]";

	$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 = "[email protected]";
	$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
https://forums.phpfreaks.com/topic/280089-need-help-using-the-mail-function/
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);

 

 

 

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!

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.