Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > Linux Forums > Server Operation

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Reply
 
Thread Tools Display Modes
  #1  
Old 21st July 2009, 23:51
bryand1 bryand1 is offline
Junior Member
 
Join Date: Apr 2009
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default Fedora 10 Server: Sending emails with php scripts

Hello,

What do I need to enable on my fedora 10 server so that I can send emails with a simple PHP mail script?

I have already opened PORT 25.

Thank you,

Bryan Andrade
Reply With Quote
Sponsored Links
  #2  
Old 22nd July 2009, 17:38
falko falko is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 41,701
Thanks: 1,900
Thanked 2,752 Times in 2,582 Posts
Default

PHP's mail() function should work out of the box.
__________________
Falko
--
Download the ISPConfig 3 Manual! | Check out the ISPConfig 3 Billing Module!

FB: http://www.facebook.com/howtoforge

nginx-Webhosting: Timme Hosting | Follow me on:
Reply With Quote
  #3  
Old 23rd July 2009, 17:24
tom.hill tom.hill is offline
Junior Member
 
Join Date: Jul 2009
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi bryand1,

I'm also having the same problem on CentOS 5.3 x64

I think we must be missing something?

Tom
Reply With Quote
  #4  
Old 29th July 2009, 18:16
tom.hill tom.hill is offline
Junior Member
 
Join Date: Jul 2009
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I wonder if anyone can help?

I have created a test page with the following code:
Code:
<?php
function send_email($from, $to, $cc, $bcc, $subject, $message){
	$headers = "From: ".$from."\r\n";
	$headers .= "Reply-To: ".$from."\r\n";
	$headers .= "Return-Path: ".$from."\r\n";
	$headers .= "CC: ".$cc."\r\n";
	$headers .= "BCC: ".$to."\r\n";
	
	if (mail($to,$subject,$message,$headers) ) {
	   echo "email sent";
	} else {
	   echo "email could not be sent";
	}
}

$subject = "Hello!";
$message = "Hello! How are you today?";
send_email("website@mydomain.net", "testadd1@domain.com", 
	"testadd2@domain.com", "hidden_email@domain.com",
	$subject , 
	$message);
?>
When I view the page above I get 'email sent' but no mail is received. If I run the command
Code:
postsuper -d ALL
I get
Quote:
postsuper: Deleted: 4 messages
so it looks to me like the messages are going into the queue? Do I have to specify my ISP's smtp relay server anywhere in the postfix config?

Kind regards,

Tom


Edit, also if I view the mail queue on Ispconfig 3 after running the test script above it shows:

Data from: 2009-07-29 16:15
/var/spool/mqueue is empty
Total requests: 0

Is this a different queue?

Last edited by tom.hill; 29th July 2009 at 18:20. Reason: additional info
Reply With Quote
  #5  
Old 3rd August 2009, 08:46
av1611 av1611 is offline
Member
 
Join Date: Jun 2007
Posts: 49
Thanks: 0
Thanked 1 Time in 1 Post
Default

I found that PHP does not work out of the box with sendmail on F10 so I got around the problem by just install postfix which took all of 10 minutes and is much easier to use anyway.

I know that's not the answer you was looking for but that's what I came up with last year when I had the same problem.
Reply With Quote
  #6  
Old 3rd August 2009, 08:48
av1611 av1611 is offline
Member
 
Join Date: Jun 2007
Posts: 49
Thanks: 0
Thanked 1 Time in 1 Post
Default

Here is the thread from last year when I tried to get it working:

http://forums.fedoraforum.org/showthread.php?t=199647
Reply With Quote
  #7  
Old 3rd August 2009, 11:19
tom.hill tom.hill is offline
Junior Member
 
Join Date: Jul 2009
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks AV,

I managed to install postfix fairly easily (yum erase sendmail, yum install postfix) and start it but my emails via my test page are still not getting through.

I'm not sure what or how to test?

Tom

Edit:

If I try to send a test email from the command line using:

echo "test" | mail -s testsubject me@hotmail.com

The email doesn't get through but defiantly joins a queue:

[root@rnetweb1 /]# postsuper -d ALL
postsuper: Deleted: 1 message

Last edited by tom.hill; 3rd August 2009 at 11:30. Reason: additional info
Reply With Quote
  #8  
Old 3rd August 2009, 11:40
av1611 av1611 is offline
Member
 
Join Date: Jun 2007
Posts: 49
Thanks: 0
Thanked 1 Time in 1 Post
Default

Try running the session in telnet:
howto:
http://tranquilpenguin.com/wordpress/?p=57

follow the example exactly and see if you get some errors. Are you on a public network? does you ISP allow you to send port 25? This is a good way to find out.
Reply With Quote
  #9  
Old 19th August 2009, 14:49
tom.hill tom.hill is offline
Junior Member
 
Join Date: Jul 2009
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks AV,

Sorry about the delay, I took a long needed holiday!

I have tried to telnet to the box from an XP machine and also to telnet to the box locally from the box itself.

from a local WinXP machine:
telnet 10.101.1.50 25

command prompt goes blank

from the box itself:
telnet 10.101.1.50 25 (or telnet localhost 25)

Trying 10.101.1.50...
Connected to host1.domain.local (10.101.1.50).
Escape character is '^]'.

and then no command has any effect (I actually have to reboot the server using XenCentre because I can't get out of the telnet prompt!)

I can telnet to my Exchange server just fine.

This must highlight a big problem somewhere, just wish I knew what it was!



Tom
Reply With Quote
  #10  
Old 20th August 2009, 16:46
falko falko is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 41,701
Thanks: 1,900
Thanked 2,752 Times in 2,582 Posts
 
Default

Are there any errors in your mail log?
__________________
Falko
--
Download the ISPConfig 3 Manual! | Check out the ISPConfig 3 Billing Module!

FB: http://www.facebook.com/howtoforge

nginx-Webhosting: Timme Hosting | Follow me on:
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Virtual Users And Domains With Postfix, Courier, MySQL And SquirrelMail -Ubuntu 8.04 c4rdinal HOWTO-Related Questions 112 23rd August 2011 11:49
Unable to install ISPConfig bdonecker Installation/Configuration 21 26th May 2009 09:20
ISPConfig virtual web pages not working mike_phi Installation/Configuration 8 7th May 2008 17:51
Can't start apache Musty Server Operation 12 9th March 2008 14:58
Apache2 Freezes celtic Server Operation 31 28th May 2007 18:18


All times are GMT +2. The time now is 07:13.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.