Jump to content


Photo

Need help using the mail function


  • Please log in to reply
3 replies to this topic

#1 eldan88

eldan88

    Advanced Member

  • Members
  • PipPipPip
  • 486 posts
  • LocationNew York

Posted 11 July 2013 - 07:39 PM

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
  
?>


#2 doddsey_65

doddsey_65

    Advanced Member

  • Members
  • PipPipPip
  • 904 posts
  • LocationNorth East UK
  • Age:26

Posted 11 July 2013 - 07:59 PM

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);

Test and help out with a new
100% open source forum package: A Simple Forum
Check the A Simple forum Github Page
Visit my Github profile to see what I work on.

#3 eldan88

eldan88

    Advanced Member

  • Members
  • PipPipPip
  • 486 posts
  • LocationNew York

Posted 15 July 2013 - 08:42 PM

 

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!



#4 eldan88

eldan88

    Advanced Member

  • Members
  • PipPipPip
  • 486 posts
  • LocationNew York

Posted 15 July 2013 - 08:47 PM

By the way, I tested it out on my remote server and it worked well.






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

Cheap Linux VPS from $5
SSD Storage, 30 day Guarantee
1 TB of BW, 100% Network Uptime

AlphaBit.com