PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old February 26th, 2013, 09:42 AM
colpaarm's Avatar
colpaarm colpaarm is offline
300lb Bench!
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Aug 2001
Location: New York
Posts: 2,343 colpaarm User rank is Sergeant Major (2000 - 5000 Reputation Level)colpaarm User rank is Sergeant Major (2000 - 5000 Reputation Level)colpaarm User rank is Sergeant Major (2000 - 5000 Reputation Level)colpaarm User rank is Sergeant Major (2000 - 5000 Reputation Level)colpaarm User rank is Sergeant Major (2000 - 5000 Reputation Level)colpaarm User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 5 Days 10 h 50 m 4 sec
Reputation Power: 60
Bizarre issue sending email with mail function

I have a chess website and email gets sent all the time. For example, if you create a new game, an email gets sent out to their opponent. This is functionality that's been working for years.

Yesterday morning, I woke up to server issues that I eventually realized were being caused every time I tried sending an email. However, when I take the send mail code and run it by itself, it appears to run fine. The code is

PHP Code:
//stuff before
if ($sEmailOfOpponent) {
sendEmail($sSubject,$sMessage,array($sEmailOfOpponent));
}
//stuff after 


$sEmailOfOpponent gets set only if the user wants to be notified by email. sendEmail contains

PHP Code:
 $sMessage formatEmailMessage($sMessage);
  
$headers  'MIME-Version: 1.0' "\r\n";
  
$headers .= 'Content-type: text/html; charset=iso-8859-1' "\r\n";
  
$headers .= 'From: support@mywebsite.com' "\r\n";
  
$headers .= 'bcc: ' join(",",$aryRecipients) . "\r\n";
  
$headers .= 'X-Mailer: PHP/' phpversion() . "\r\n";

  
mail('noreply@nothingbutchess.com',$sSubject,$sMessage,$headers); 


formatEmailMessage literally does that. It puts my company logo, wraps the message in a little html, nothing special. I've confirmed that if I comment out the sendEmail call, everything works fine. If I don't, things work.....eventually. 15-20 seconds later. Sometimes the gateway times out before hand. I want to stress:
  • This code hasn't been updated in years
  • This code has been working for years
  • The problems started yesterday morning
  • When I isolate the mail send function by itself it sends mail just fine
  • When I comment out the send mail function, everything works (other than mail getting sent)
  • When I combine the two…problems (even though I probably haven't made a change to this section of the code in at least 2 years.

All things considered, I'm POSITIVE that the issue is not with me but with the mail server. However, /var/log/maillog is empty and of course my hosting company will only do so much in the way of diagnostics. Anybody ever see anything like this before?
__________________
Correspondence chess
nothingbutchess.com

Reply With Quote
  #2  
Old February 26th, 2013, 09:57 AM
gw1500se gw1500se is online now
Contributing User
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Jul 2003
Posts: 2,879 gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level) 
Time spent in forums: 1 Year 2 Weeks 1 Day 22 h 20 m 37 sec
Reputation Power: 581
Was your MTA changed/updated? When you say the log file is empty do you mean is it 0 bytes or that you didn't see anything pertaining to this problem? If the former, you need to have Postfix logging turned on. There may be errors but they are not being logged.
__________________
There are 10 kinds of people in the world. Those that understand binary and those that don't.

Reply With Quote
  #3  
Old February 26th, 2013, 09:58 AM
colpaarm's Avatar
colpaarm colpaarm is offline
300lb Bench!
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Aug 2001
Location: New York
Posts: 2,343 colpaarm User rank is Sergeant Major (2000 - 5000 Reputation Level)colpaarm User rank is Sergeant Major (2000 - 5000 Reputation Level)colpaarm User rank is Sergeant Major (2000 - 5000 Reputation Level)colpaarm User rank is Sergeant Major (2000 - 5000 Reputation Level)colpaarm User rank is Sergeant Major (2000 - 5000 Reputation Level)colpaarm User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 5 Days 10 h 50 m 4 sec
Reputation Power: 60
It's 0 bytes. Ok, I'll try and get the logs turned on.

Reply With Quote
  #4  
Old February 27th, 2013, 01:57 PM
colpaarm's Avatar
colpaarm colpaarm is offline
300lb Bench!
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Aug 2001
Location: New York
Posts: 2,343 colpaarm User rank is Sergeant Major (2000 - 5000 Reputation Level)colpaarm User rank is Sergeant Major (2000 - 5000 Reputation Level)colpaarm User rank is Sergeant Major (2000 - 5000 Reputation Level)colpaarm User rank is Sergeant Major (2000 - 5000 Reputation Level)colpaarm User rank is Sergeant Major (2000 - 5000 Reputation Level)colpaarm User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 5 Days 10 h 50 m 4 sec
Reputation Power: 60
While I wasn't able to turn on logging on the mail server, I was able to produce a working example of what's causing my issue.

Steps are:

1. Do a mysql insert with two fields. One is just an id. The other is a longtext field that will have between 20kb and 40kb of data (serialized object).
2. Send out an email
3. Wait 10 seconds
4. Repeat steps one and two

The second time around the process takes 15-20 seconds to complete. Again, I've been doing this for years. Literally, my database has over 2,000 games like this without a single issue. Any other thoughts?

It almost doesn't seem to be a mail server issue per se. Because when it hangs, I check the mail server. Sometimes it hangs and the data hasn't reached the mail server (I'm watching it). I'm beginning to suspect that it's a *routing* issue. As in, the darn thing is probably struggling to figure out where to route the thing. Although why it would be able to figure it out the first time no problem? I'm stumped at this point.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > Bizarre issue sending email with mail function

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap