<?php /* Author: Ivan Kristianto Website: http://www.ivankristianto.com Disclaimer: This code is to export all your comentor's email to csv format. Feel free to use it. And i'm not responsible for any legal or ILEGAL activity use of this script. Use it with your own risk! */ $database_host="localhost"; //Your MySQL host, leave it to default if you don't understand what is it. $database_name=""; //Your MySQL database name $database_username=""; //Your MySQL database username $database_password=""; //Your MySQL database password //You don't have to change the rest unless you understand what you are doing. mysql_connect ($dbhost, $database_username, $database_password) or die("error");; mysql_select_db($database_name); $query = "SELECT DISTINCT `comment_author_email` , `comment_author` , `comment_author_url` FROM `wp_comments` WHERE `comment_approved`=1 AND `comment_type` != 'pingback' AND `comment_author_email` <> ''"; $csv_output = ''; $csv_output .= '"Name","Email","Website URL"'; $csv_output .= "\015\012"; $result = mysql_query($query); while($row = mysql_fetch_array($result)) { $csv_output .= '"'.$row[comment_author].'","'.$row[comment_author_email].'", "'.$row[comment_author_url].'"'; $csv_output .= "\015\012"; } //You cannot have the breaks in the same feed as the content. header("Content-type: application/vnd.ms-excel"); header("Content-disposition: csv; filename=email-export.csv"); print $csv_output; exit; ?>