Koozali.org: home of the SME Server

PHP Mail function

BeeBeeDesign

PHP Mail function
« on: December 27, 2006, 02:35:47 PM »
Hi Guys and Girls,

This is my first post on the forum, so I hope it isn't one of those that gets asked every day! I have tried to search for the answer but no luck. :(

Ok, so I have an install of SME Server v7 running a PHP based CRM system for a client. one part of this CRM requires the use of the PHP mail function to send emails. This is not working. The following code returns "MAIL NOT SENT" meaning that the message is not being submitted to the SMTP server correctly:

Code: [Select]

if (mail('**address removed**', 'This is just a quick test')) echo "MAIL SENT";
else echo "MAIL NOT SENT";


The server is running in server only mode and none of the mail features are being used. I am guessing that this issue is caused by incomplete configuration somewhere but I can't find anything that looks right!

Can you help me please?

Ta,

Ben

Offline CharlieBrady

  • *
  • 6,918
  • +3/-0
Re: PHP Mail function
« Reply #1 on: December 27, 2006, 05:13:00 PM »
Quote from: "BeeBeeDesign"

Can you help me please?


You probably should ask on a PHP programming forum.

Offline bpivk

  • *
  • 908
  • +0/-0
    • http://www.bezigrad.com
PHP Mail function
« Reply #2 on: December 27, 2006, 08:16:34 PM »
Php mail function works on my server. What system are you using?
"It should just work" if it doesn't report it. Thanks!

Offline cool34000

  • *
  • 339
  • +0/-0
PHP Mail function
« Reply #3 on: December 27, 2006, 08:58:55 PM »
Have you configured at least the server name (should be localhost) and server port (should be 25) in your CMS admin's page ?

Offline bpivk

  • *
  • 908
  • +0/-0
    • http://www.bezigrad.com
PHP Mail function
« Reply #4 on: December 27, 2006, 09:52:08 PM »
As far as i know only server name is required for php mail to work. At least at sites that i'm using.
"It should just work" if it doesn't report it. Thanks!

Offline byte

  • *
  • 2,183
  • +2/-0
PHP Mail function
« Reply #5 on: December 27, 2006, 11:14:32 PM »
Moving this topic to the General Discussion forum, it is more appropriate there. Thanks!
--[byte]--

Have you filled in a Bug Report over @ http://bugs.contribs.org ? Please don't wait to be told this way you help us to help you/others - Thanks!

BeeBeeDesign

PHP Mail function
« Reply #6 on: December 28, 2006, 02:12:20 PM »
Ok. So the reason that the above script wasnt working was that I was missing a message!! Having corrected that, I am now getting a MAIL SENT response.

However, no emails are appearing in my inbox. The positive response from the script means that the mail is being correctly submitted to the mail server but thats all.

I have the eSmith server running on a LAN behind a router and am trying to configure the SMTP server setting in the Server Manager so that "Address of Internet provider's mail server" is set to my ISP's SMTP server, which does not require authentication. When I run a phpinfo() with these settings showing in the Server Manager, the sendmail_path is still set to "/usr/sbin/sendmail -t -i".

This is the latest qmail log entry:

2006-12-28 13:11:29.583779500 new msg 227257
2006-12-28 13:11:29.583784500 info msg 227257: bytes 294 from <anonymous@crm-server.local> qp 3708 uid 102
2006-12-28 13:11:29.653849500 starting delivery 20: msg 227257 to remote post@beebee-design.co.uk
2006-12-28 13:11:29.653853500 status: local 0/10 remote 1/20


I don't have much experience with mail servers, so don't really know what this is telling me. Can any of you guys shed any light on the situation for me?

Ta,

Ben

BeeBeeDesign

PHP Mail function
« Reply #7 on: December 28, 2006, 02:13:52 PM »
And the response from the mail server comes back as:

2006-12-28 13:11:49.658397500 delivery 20: deferral: Sorry,_I_couldn't_find_any_host_by_that_name._(#4.1.2)/
2006-12-28 13:11:49.658403500 status: local 0/10 remote 0/20

Offline Smitro

  • *
  • 349
  • +0/-0
PHP Mail function
« Reply #8 on: December 29, 2006, 03:14:05 AM »
Out of curiosity, can you send mail through webmail?
Is the address you're trying to send to external or internal?
.........

BeeBeeDesign

PHP Mail function
« Reply #9 on: December 29, 2006, 01:03:35 PM »
No idea. We are not using the mail server component of SME Server as the client already has a full Windows infrastructure.

Offline Gaston94

  • ****
  • 184
  • +0/-0
PHP Mail function
« Reply #10 on: December 29, 2006, 03:52:01 PM »
Hello,
most likely this kind of message came with some wrong DNS configuration.
Could you check from the SME server that you can success in following test :
Code: [Select]
#  mail -s "check domaine delivery" your@add.mail
test delivery
.
cc:
# nslookup -q=mx add.mail

You should get :
 - the trace of the outgoing in your logfile
 - the IP adress of the mx serveur you tried to reach

Should you not success in the nslookup stuff, check which are the DNS setting for the SME, are you using one of the Internet root servers (or you ISP DNS servers )?

G.
[edit] fix wrong char in nslookup query [/edit]

Offline Smitro

  • *
  • 349
  • +0/-0
PHP Mail function
« Reply #11 on: December 29, 2006, 11:13:37 PM »
Quote from: "BeeBeeDesign"
No idea. We are not using the mail server component of SME Server as the client already has a full Windows infrastructure.


How long does it take to check? (5 mins tops) In order to get help you got to want to help yourself.

I think Gaston94's probably got a good way to test. Alternatively what I do is send a test email via the command line.

Code: [Select]
# mail email@dress.to.test
Subject: Test Message
This is the message content.
.
Cc:


Hit enter after each line. When you've finished the message use a '.' on a new line.
.........

BeeBeeDesign

PHP Mail function
« Reply #12 on: January 10, 2007, 07:38:08 PM »
Hi guys,

Thank you so much for your help and advice with this. And sorry for not exploring the obvious things like webmail. I know how frustrating it can be to try to help someone that doesnt appear to be helping themselves from forums I participate in where I have the knowledge.

I have tried your suggestions and have got the following results:

Quote

[root@crmsystem ~]# mail post@beebee-design.co.uk
Subject: Test
.
Cc:
Null message body; hope that's ok
[root@crmsystem ~]# nslookup -q=mx beebee-design.co.uk
Server:         192.168.0.202
Address:        192.168.0.202#53

Non-authoritative answer:
beebee-design.co.uk     mail exchanger = 0 beebee-design.co.uk.

Authoritative answers can be found from:

[root@crmsystem ~]#


When I set up the webmail, I had some returned mails saying that authorisation had failed, which was corrected by specifying the correct mail server with the correct password! However, these are no longer appearing.

Looking in the qmail logs, I can see messages being sent out and a response saying 250 OK from an IP address that I dont recognise, but am assuming is the external mail server (it doesnt start in 192).

I am really struggling with this one, so any help at all is muchly appreciated!  :)

Offline CharlieBrady

  • *
  • 6,918
  • +3/-0
PHP Mail function
« Reply #13 on: January 10, 2007, 08:11:49 PM »
Quote from: "BeeBeeDesign"

Looking in the qmail logs, I can see messages being sent out and a response saying 250 OK from an IP address that I dont recognise, but am assuming is the external mail server (it doesnt start in 192).

I am really struggling with this one, so any help at all is muchly appreciated!  :)


Nobody can help you except the admin of the machine which accepted the mail and didn't deliver it to the intended recipient. I'm guessing that is the admin of beebee-design.co.uk, whose mail exchanger is at 72.9.231.10.

It's not a problem at your end.

BeeBeeDesign

PHP Mail function
« Reply #14 on: January 10, 2007, 09:57:53 PM »
Well that sounds like progress to me!

Just to clarify, here is a log entry from just now:

Quote

2007-01-10 20:51:48.076521500 status: local 0/10 remote 0/20
2007-01-10 20:51:48.380561500 starting delivery 1: msg 1115398 to remote post@beebee-design.co.uk
2007-01-10 20:51:48.412256500 status: local 0/10 remote 1/20
2007-01-10 20:51:49.451159500 delivery 1: success: 195.188.53.60_accepted_message./Remote_host_said:_250_OK_id=1H4kPx-000305-V4/
2007-01-10 20:51:49.493104500 status: local 0/10 remote 0/20
2007-01-10 20:51:49.566197500 end msg 1115398


Does this definitely mean that the message has been accepted by my ISPs smtp server?

BeeBeeDesign

PHP Mail function
« Reply #15 on: January 10, 2007, 10:43:57 PM »
In case one of you guys can spot something wrong, here is some more info:

Quote

Review configuration
Networking Parameters
Server Mode serveronly
Local IP address / subnet mask 192.168.0.202/255.255.255.0
Gateway 192.168.0.1
Additional local networks 192.168.0.0/255.255.255.0
DHCP server disabled
Server names
DNS server 192.168.0.202
Web server www.dnsalias.com
Proxy server proxy.dnsalias.com:3128
FTP server ftp.dnsalias.com
SMTP, POP, and IMAP mail servers mail.dnsalias.com
Domain information
Primary domain dnsalias.com
Virtual domains dnsalias.com
Primary web site http://www.dnsalias.com
Server manager https://beebee/server-manager/
User password panel https://beebee/user-password/
Email Addresses useraccount@dnsalias.com
firstname.lastname@dnsalias.com
firstname_lastname@dnsalias.com

Quote

E-mail settings
POP3 server access  Allow private
IMAP server access  Allow private
Webmail access  Allow HTTPS (secure)
 
--------------------------------------------------------------------------------
 
Virus scanning  Enabled
Spam filtering  Disabled
Executable content blocking  Disabled
 
--------------------------------------------------------------------------------
 
E-mail retrieval mode  Standard (SMTP)
SMTP authentication  Allow SSMTP (secure)
 
--------------------------------------------------------------------------------
 
Forwarding address for administrative notices  
E-mail to unknown users  Send to administrator
Address of internal mail server  
Address of Internet provider's mail server  smtp.blueyonder.co.uk

Offline CharlieBrady

  • *
  • 6,918
  • +3/-0
PHP Mail function
« Reply #16 on: January 11, 2007, 06:13:29 PM »
Quote from: "BeeBeeDesign"
Well that sounds like progress to me!

Just to clarify, here is a log entry from just now:

Quote

2007-01-10 20:51:48.076521500 status: local 0/10 remote 0/20
2007-01-10 20:51:48.380561500 starting delivery 1: msg 1115398 to remote post@beebee-design.co.uk
2007-01-10 20:51:48.412256500 status: local 0/10 remote 1/20
2007-01-10 20:51:49.451159500 delivery 1: success: 195.188.53.60_accepted_message./Remote_host_said:_250_OK_id=1H4kPx-000305-V4/
2007-01-10 20:51:49.493104500 status: local 0/10 remote 0/20
2007-01-10 20:51:49.566197500 end msg 1115398


Does this definitely mean that the message has been accepted by my ISPs smtp server?


Yes, that's usually what "accepted message" means :-)

Your ISP's mail server, smtp.blueyonder.co.uk at 195.188.53.60, accepted the message for post@beebee-design.co.uk. If it wasn't delivered, then you'll need to ask them why it wasn't. If you quote 'id=1H4kPx-000305-V4/' to them, that might help them in tracking.

I hope that you sent the mail with a valid return address. That way you are able to receive a bounce message if your message cannot be delivered.

Note that none of this has anything to do with SME server, which is doing just what it should be doing.

BeeBeeDesign

PHP Mail function
« Reply #17 on: January 11, 2007, 08:53:46 PM »
My test emails arrived about 2 hours ago so it is now working!!! Thank you all so much for your help!

Although it has been a frustrating episode, I have definitely learnt a few things. Once again, apologies for the newbie questioning style.  :wink:

It seems to me that the issue was indeed down to DNS, as when I gave the server a dyndns hostname it started working once the DNS updates filtered through the internet.