Server not serving XML correctly?

Wednesday 03/12/2008  –  Category: Uncategorized  –  No Comments

I ran into this issue with a Drupal plugin (FCKeditor) today where an XML file wouldn’t load. it turned out to be a server configuration issue where Apache wasn’t serving XML files as it should, so the ajax request wasn’t processed correctly. To get Apache to serve XML files correctly, add this line to your .htaccess:

AddType text/xml xml

1) Locate your maillog (usually in /var/log)

2) If you cat the file, you’ll get output something like:

    Jan 27 01:19:28 145856-web1 postfix/smtp[8994]: DAA77A74568: to=, relay=none,
delay=388925, status=deferred (connect to noemail.org[82.98.86.165]: Connection refused)

3) we want to check for “status=deferred” or “status=bounced”. we’ll do this with the grep command:

    grep “status=bounced” /var/log/maillog | grep -o -P “to=<(.+?)>” > bounces.log

(you may have to sudo if you’re not logged in as root)

The first half grabs the lines from the log that match the status string.

We just want the email addresses, so we use the pipe operator to pass it on for trimming. Using the -o flag you can get exactly what you want from the matching regex (-P flag). In this case, we see the emails are always surrounded by to=<>”.

Your output (saved to bounces.log) should look something like:

 
to=<adf@asdfa.com>
to=<af@asdf.com>
to=<dfda@fad.COM>
to=<adsfa@df.net>
to=<fd@adf.com>
 

I wanted to get the emails nice and trimmed in an array for use in a Rails app:

 
bounce_array = []
unique_array = []
 
File.open(“PATH/TO/LOGS/bounces.log”, “r”) do |maillog|
  i = 0
  maillog.each_line do |line|
 
     puts “Got email #{i} #{$1}”  if line =~ /to=<(.+?)>/i
     i = i + 1
     bounce_array « $1.to_s
  end   
 
  unique_array = bounce_array.select{|e| bounce_array.index(e) !=
    bounce_array.rindex(e)}.uniq
end
 
unique_array.each do |e|
 puts e
end
 

Check your line endings!

Tuesday 01/22/2008  –  Category: Uncategorized  –  No Comments

I had a problem with a file today that had a bunch of ^M breaks that was causing the class to not load correctly. if you ever run into a problem with a particular file, check your line endings!

“The different newline conventions often cause text files that have been
transferred between systems of different types to be displayed
incorrectly. For example, files originating on Unix or Apple Macintosh systems may appear as a single long line on a Windows system. Conversely, when viewing a file from a Windows computer on a Unix system, the extra CR may be displayed as ^M at the end of each line or as a second line break.”

[via wikipedia]

Thanks notch8 for narrowing down the problem to a single file. I was going crazy trying to figure out if it was a problem with rails requires and dependencies…

PHP mail

Tuesday 12/18/2007  –  Category: Uncategorized  –  No Comments

How to use the often overlooked fourth parameter while using mail function in php:

bool mail  ( string $to  , string $subject  ,   string $message    [, string $additional_headers    [, string $additional_parameters  ]] )

The additional_parameters parameter can be used to pass an additional parameter to the program configured to use when sending mail using the sendmail_path configuration setting. For example, this can be used to set the envelope sender address when using sendmail with the -f sendmail option.

The user that the webserver runs as should be added as a trusted user to the sendmail configuration to prevent a ‘X-Warning’ header from being added to the message when the envelope sender (-f) is set using this method. For sendmail users, this file is /etc/mail/trusted-users.

Example usage:

mail($email, $subject, $body, $headers, ‘-fnoreply@mydomain.com’)

When using flvtool2 to trim flv’s…

Friday 12/14/2007  –  Category: Uncategorized  –  No Comments

Use the -a switch to collapse space between cut regions (i.e. resets duration and keyframes from 0)

 Page 12 of 13  « First  ... « 9  10  11  12  13 »