Solved

Dedicated server, hosting a PHP script, which is emailing a notification of a form filled out, and the emails are bouncing.

Posted on 2007-11-17
22
1,065 Views
Last Modified: 2013-12-18
Dedicated server, hosting a PHP mail script, which is emailing the results of a form entry -- the notification email, though, is bouncing with the error indicated above.  The email addresses (on different servers and two different domains) function perfectly and the script works on other servers without a problem as well.

The email is returned (to the nobody@ address for the ded. server) as undeliverable by the server.  (NOT the recipient server, but the _sending_ server.

Email and header are as follows (domain names are purposefully obscured to protect the innocent -- me -- from SPAM and the other nasty variants):

This message was created automatically by mail delivery software.

A message that you sent could not be delivered to one or more of its
recipients. This is a permanent error. The following address(es) failed:

 darren@XXXXX.com
   SMTP error from remote mail server after end of data:
   host k2smtpout-v01.prod.mesa1.secureserver.net [64.202.189.86]:
   554 Message refused.

------ This is a copy of the message, including all the headers. ------

Return-path: <nobody@host.XXXXX.com>
Received: from nobody by host.XXXXX.com with local (Exim 4.68)
      (envelope-from <nobody@host.XXXXX.com>)
      id 1ItdJV-0000vx-2E
      for darren@digispire.com; Sun, 18 Nov 2007 01:07:25 -0500
To: darren@XXXXX.com
Subject: Quote Request
MIME-Version: 1.0
From: "test <no-reply@AAAAAAA.com>
Content-type: text/plain; charset=iso-8859-1
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 7bit
Message-ID: <jroucd.s5es2a@AAAAAAA.com>
Date: Sun, 18 Nov 2007 01:07:25 -0500
0
Comment
Question by:digispire
  • 11
  • 9
22 Comments
 
LVL 16

Expert Comment

by:grahamnonweiler
ID: 20306846
It appears you may be using GoDaddy's dedicated servers - and if so they have some pretty funky rules about using their SMTP services - vis a vis SmartHosts and the like.  

For PHP to be able send mail messages using the "MAIL" function the server sending the message needs to be defined as a "trusted" host - the 554 error message you are getting relates to authentication, in that the sending server requires authentication before accepting a message for relay. Typically in a dedicated server environment you mark each of your servers as "trusted" so that authentication is not required of PHP by the SMTP server.

If the SMTP service is on the same server then it is quite simple, as you define "127.0.0.1" as a trusted host - if however SMTP is on another server then on the SMTP server you need to define the IP address of the server running PHP  as a trusted host.

From the above error message it does look as if you have set your PHP scripts to use the main GoDaddy outgoing SMTP services, and that might cause problems. You would be better to run a SMTP service on one of your own servers (letting PHP send to that server) and then in turn set up your SMTP server to Smarthost as required by your hosting provider.

0
 

Author Comment

by:digispire
ID: 20307673
This is a great response -- and very helpful!  You're absolutely right -- the script is on an account on a GoDaddy dedicated server.  I cannot run the script from my own server as all accounts are on this dedicated box!  So, that leaves me with your suggestion.

I'm confused on one thing -- the script is using sendmail (not SMTP) -- not sure why this should be an issue if using sendmail!  (See the code attached below to see the configuration -- I DO have the option to run it using SMTP, but that is more of a burden on the server.)

Finally, how/where do you add a server as a trusted host?  (Using GoDaddy's server environment)  I have cPanel, if that helps.

Thanks!!
 * Configuration

 */

$configuration = array();

$configuration['mail_type']     = 'mail'; // (mail, smtp)

$configuration['mail_from']     = 'postmaster@' . $_SERVER['SERVER_NAME'];
 

$configuration['smtp']['host']  = 'example.com';

$configuration['smtp']['port']  = 25;

$configuration['smtp']['helo']  = $_SERVER['SERVER_NAME'];

$configuration['smtp']['auth']  = true;

$configuration['smtp']['user']  = '';

$configuration['smtp']['pass']  = '';
 

$configuration['character_set']     = 'iso-8859-1';

$configuration['check_user_agent']  = false;

$configuration['strip_injections']  = true;

$configuration['captcha_image']     = (isset($captcha) and $captcha == 'yes') ? true : false;

$configuration['captcha_font_path'] = getenv('DOCUMENT_ROOT') . dirname($_SERVER['PHP_SELF']) . '/inc/font/';  // Alternative path: $captcha_font_path = SCRIPT_ROOT . 'inc/font/';  

$configuration['garbage_collector'] = true;

$configuration['gc_number']         = 20; // Number of files to be deleted at once

$configuration['gc_time']           = 60; // Minutes until a garbage file gets deleted
 

$configuration['allowed_recipients_domains'] = ''; // Separated by comma
 

$configuration['temp_folder']       = (defined('F6L_TEMP_FOLDER')) ? F6L_TEMP_FOLDER : $script_root . 'temp/';

Open in new window

0
 
LVL 16

Expert Comment

by:grahamnonweiler
ID: 20308037
Actually using sendmail is more practical with a Linux box - I thought you might be using a windows server and in which case SMTP with PHP is the only option.

In the above script (line 10) you are specifying that SMTP authentication is required (true) - but you have not defined an account and password (line 11 and 12). This could well be why you are getting unauthenticated bounces.

It will probably be easier for you to create a "control" account on your SMTP server - and then enter those details in to your script (including the username and password to authenticate with) - than it will be to set up trusted hosts.

Try chnging your script as suggested here a post back the results (including your PHP logs if you still get an error).
0
 

Author Comment

by:digispire
ID: 20308128
Actually, those 'SMTP' settings lines are only if you have SMTP enabled -- which, if you see on line 4, it is not.  It does seem confusing when you look at it this way.

Excuse a newb for his ignorance -- but where do I find the PHP logs?  Also, what sort of control account should I set up?  Are you saying I should set up an SMTP server on the box to handle any SMTP request and then configure the script to use SMTP (instead of sendmail)?

Sorry -- I know I seem to know more than I do!!
0
 
LVL 16

Expert Comment

by:grahamnonweiler
ID: 20308476
Sorry for jumping ahead too quickly.

Sendmail still needs to authenticate against the GoDaddy server in some way (rather like smarthosting) - or else you will have to manually point your script at an internal server (meaning another GoDaddy dedicated box you operate) and set up trusted hosts on that server.  I was trying to avoid the need to set-up trusted hosts as far as possible.

If you only have one server with GoDaddy then the safest way forward (because of the GoDaddy restrictions) would be for you to start an SMTP service on the box you are running your PHP scripts from, and in turn create a single account that you can use to send PHP messages through.

If you have 2 (or more servers) and on one of them you are running an SMTP service then manually direct your scripts to relay through that server.

As for finding your PHP logs - typically they will be beside your Apache logs - although it may be that your implementation of PHP does not write errors to a file.

Lets try taking it a step at a time, let me know if either of the above scenarios is possible in your current set-up.
0
 

Author Comment

by:digispire
ID: 20308570
I have several accounts on the main server, including the domain of the server's hostname.  I went ahead and set up an SMTP account there, set up a new user, and tried to use the settings I set up -- same error was returned and the email was bounced.

Here is the scenario:  I have one dedicated box and the account in question (the one hosting this form) is on that box, along with a couple dozen other accounts.  I don't have another box to use -- so whatever solution I come up with has to be on this box.  

Here is the kicker:  the account in question is hosting their email EXTERNALLY, so I do not want to set up mail accounts, since that will confuse the server as to where to send the mail to, and they will not be checking their email on this server!

Regarding logs, I have the option to download Raw Apache logs or Raw FTP logs -- don't see anything for PHP.  However, I can ssh in and access the root dir, if I knew where to fish!

Maybe we should start with the trusted host solution?

Thank you very much for your help!!

0
 
LVL 16

Expert Comment

by:grahamnonweiler
ID: 20308620
I think I can see where the problem may lay.

First a few questions:

Do you have a domain for which you are hosting email (for instance your "control" domain that is yours) on one of the GoDaddy servers.

From what email address (specifically the domain) are you trying to send the FORM responses from (the domain must exist  and to meet GoDaddy requirements that domain's mail  needs to be on a GoDaddy server)

Have you set-up any one of your servers to send email as instructed by GoDaddy - remember they insist  that you send all email through their SMTP servers,  and you have a maximum limit of 1,000 emails per day.

Last, how have you configured sendmail - in so much as are you trying to let sendmail "directly" transmit messages or have you set it up to smarthost through GoDaddy's SMTP servers?

0
 

Author Comment

by:digispire
ID: 20308693
I'm going to try to respond the best I can -- but may need some help from you in explaining!

I have not yet had a domain for hosting my own email, until I set that up just a short while ago, to test the SMTP settings as you'd mentioned.  So NOW I do, I just do not use that domain for any serious emailing (or have not yet done so, that is!)  My main email account is still on a shared environment at another company.  There are, however, several other accounts on this dedicated server that are hosting email, with no issues, currently.

You raise a whole other issue, here, though -- about what the FROM email address is -- that is, in fact, a fictional one, but a real domain hosted on the same account the form is on.  I'll go and try, now, to set that up -- however, again the MX records may be an issue, since I don't want inbound email to get trapped on the server (this client is hosting their email externally!)  Any ideas on that?

I didn't know GoDaddy was so strict about all this -- yes, as mentioned above, several accounts are configured to use the GoDaddy SMTP (are you talking about their OWN SMTP server, or one that is hosted on the dedicated server?  I've not seen anything that indicated I had to use theirs!  For example, if we had acme.com hosted on the dedicated, we set up mail.acme.com to act as POP server and SMTP server, and had no issues with either configuration or usage.  That is, SMTP works for those clients without a hitch.)

Your last question has me stumped the most!  I never "configured" sendmail, and would not even know where to begin to do that!  Are you referring to the actual PHP configuration file?  Let me know -- I can paste my php config for you here, if that would help!

Again, thanks!
0
 
LVL 16

Expert Comment

by:grahamnonweiler
ID: 20308759
OK, now we are getting closer to the root of the problem.

First, do not change any DNS settings for the particular domain you have the problem with.

What I suggest you try now BEFORE doing anything else - is set your script to send the FORM data from "postmaster@ ----- the domain name that you say above you have just set up----"

Leave everything else in the script as it was and lets see what happens this time.

I think the original cause of your problem was that you were sending an email from a "fictious or non-existent" domain - this would really upset GoDaddy!

They set up all of their servers so that you can not directly send over port 25 - you can receive directly but not send. All outgoing SMTP traffic is channeled through their SMTP servers and they cut you off if you exceeed your daily limit of 1000 emails. Part of what they like to call "spam" control - in reality their servers are just as bad anyone else when it comes to spewing out junk.

By the way I guess you are using cPanel on Linux?
0
 
LVL 16

Expert Comment

by:grahamnonweiler
ID: 20308762
Sorry, can you post the portion of your PHP ini file here that deals with SMTP and Sendmail.
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:digispire
ID: 20309019
First, tried your suggestion, and it failed the same way again.

Second, yes, cPanel on Linux (CentOS or maybe it is Fedora?)

Third, php.ini excerpt below: (didn't know which php.ini file is the one being used -- found at least two, in different locations -- this one is the one I got by running php -i | grep php.ini)
[mail function]

; For Win32 only.

;SMTP = localhost;

smtp_port = 25
 

; For Win32 only.

;sendmail_from = me@localhost.com;
 

; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").

sendmail_path = /usr/sbin/sendmail -t -i;

Open in new window

0
 
LVL 16

Expert Comment

by:grahamnonweiler
ID: 20309092
Can you post the last bounce message that you got - specifcally I need to see the headers.

Can you mark the domain that you are sending the email out as "mydomain.com" and the domain for your client (website) as "theotherdomain.com"

I still think the problem is directly related to the way the headers (sent from, reply to etc) appear when they hit GoDaddy's SMTP servers.
0
 

Author Comment

by:digispire
ID: 20309152
Headers attached below -- in the interim, I've tested a couple things -- there were options in the email script to change some settings if mail was not going out -- I tried that, and did not work.  I also set up a very simple mail script, which was delivered handily, so I know there is no issue there!

This is definitely some sort of server problem or DNS issue (though I think it is more likely some server config!)

Also, don't know if this should matter one bit, but I added the actual header of the email sent to me from the server's Mailer Daemon, and pasted it below the asterisks below (*********).  The first part are the headers given to me by the daemon for the error -- don't have my client's server in here anywhere, actually -- it is now set to use the hostname of the server.  So, this is the naming convention:  Recipient of Email:  name@mydomain.com / Sender of Email: servername.com
This message was created automatically by mail delivery software.
 

A message that you sent could not be delivered to one or more of its

recipients. This is a permanent error. The following address(es) failed:
 

 name@mydomain.com

   SMTP error from remote mail server after end of data:

   host k2smtpout-v01.prod.mesa1.secureserver.net [64.202.189.86]:

   554 Message refused.
 

------ This is a copy of the message, including all the headers. ------
 

Return-path: <nobody@host.servername.com >

Received: from nobody by host.servername.com with local (Exim 4.68)

	(envelope-from <nobody@host.servername.com>)

	id 1ItrhP-0000gD-CD

	for name@mydomain.com; Sun, 18 Nov 2007 16:29:03 -0500

To: name@mydomain.com>

From: "debug <postmaster@servername.com>

MIME-Version: 1.0

Content-type: text/plain; charset=iso-8859-1

Subject: Custom Quote Request

Message-Id: <E1ItrhP-0000gD-CD@host.servername.com>

Date: Sun, 18 Nov 2007 16:29:03 -0500
 

**************************************
 

From: 	Mailer-Daemon@host.servername.com

Subject: 	Mail delivery failed: returning message to sender

Date: 	November 18, 2007 4:29:03 PM EST

To: 	nobody@host.servername.com

Return-Path: 	<>

Received: 	from k2smtpout05-02.prod.mesa1.secureserver.net [64.202.189.57] by mail22.safesecureweb.com with SMTP; Sun, 18 Nov 2007 16:29:10 -0500

Received: 	(qmail 5200 invoked from network); 18 Nov 2007 21:29:09 -0000

Received: 	from unknown (HELO host.servername.com) (208.109.236.159) by k2smtpout05-02.prod.mesa1.secureserver.net (64.202.189.57) with ESMTP; 18 Nov 2007 21:29:09 -0000

Received: 	from mailnull by host.servername.com with local (Exim 4.68) id 1ItrhP-0000gG-H7 for nobody@host.servername.com; Sun, 18 Nov 2007 16:29:03 -0500

X-Failed-Recipients: 	name@mydomain.com

Auto-Submitted: 	auto-replied

Message-Id: 	<E1ItrhP-0000gG-H7@host.servername.com>

X-Rcpt-To: 	<name@my-other-domain.com>

Open in new window

0
 
LVL 16

Expert Comment

by:grahamnonweiler
ID: 20309183
when you say " I also set up a very simple mail script, which was delivered handily" do you mean you wrote and ran a script on the same server as this problematic one and it sent an email correctly?
0
 

Author Comment

by:digispire
ID: 20309195
Yep
<?php

 

mail('name@mydomain.com', 'Mail Test', 'Mail Works!');

 

?>

Open in new window

0
 

Author Comment

by:digispire
ID: 20309244
SOLVED!  I have NO idea why, but the server required the following line in the header of the email:

Sender: you@example.com
(instead of From: you@example.com which was what was there before!)

Thank you so much for your help -- you've been OUTSTANDING!
0
 
LVL 16

Accepted Solution

by:
grahamnonweiler earned 500 total points
ID: 20309329
I was pretty sure it was a problem with the sending domain - in the bounce message the "host." portion of the domain was really giving me concerns - GoDaddy is a real pain in the a** when it comes to this type of thing.

One thing to keep in mind with the GoDaddy is that there support is non-existent!

Anyway at the end of the day you have achieved what you wanted to do - and thats the main thing.

Cheers.
0
 
LVL 16

Expert Comment

by:grahamnonweiler
ID: 20309339
One small extra pointer - when using PHP to send out emails it is best to create ALL of the headers manually. There are some classes around that will do it for you - but most of these are really over the top as creating mail headers are quite straight forward. However, as you have just found out, not setting the headers properly can have some disasterous affects!
0
 

Author Comment

by:digispire
ID: 20309435
Their support is why I became a member of Experts Exchange!!  ;-)

I will heed your advice moving forward!  Thank you, again.

I do have one more question that is related, but it is actually a different issue -- let me know if you think I should post this in a new thread:

Recall that I said this client has an external mail server -- when sending this form, now, to any other domain, it is not an issue -- however, when sending to THIS domain (which is the intended goal here) it attempts local delivery and, of course, fails.  How do you disable local delivery?
0
 
LVL 16

Expert Comment

by:grahamnonweiler
ID: 20321143
Well if the MX records for the domain are correctly set then it shouldn't be attempting local delivery - in that it should go out over SMTP in the same way as any other non-local domain.

If you are hosting the DNS for the domain then make sure all of the MX records point to extermal servers and also that you do not have any local mail servers set -up with this domain mentioned.
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Workplace bullying has increased with the use of email and social media. Retain evidence of this with email archiving to protect your employees.
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now