473,385 Members | 1,492 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

get all the email addresses from a text file

Hi,

I have a .txt file with a lot of text mixed with some email addresses. I
would like to get all the email addresses in a $mails[] variable. Does
anyone know how to do this in php.

Thanks a lot for your help,

Nicholas
Mar 22 '06 #1
4 3171

Nico wrote:
Hi,

I have a .txt file with a lot of text mixed with some email addresses. I
would like to get all the email addresses in a $mails[] variable. Does
anyone know how to do this in php.

Thanks a lot for your help,

Nicholas


What does the .txt file look like? (Please don't say HTML)

Mar 22 '06 #2

"ZeldorBlat" <ze********@gmail.com> a écrit dans le message de news:
11**********************@g10g2000cwb.googlegroups. com...
What does the .txt file look like? (Please don't say HTML)

Well it looks like that :
Email : bo*********@wanadoo.fr
Errors : 3
Reason : 550 <bo*********@wanadoo.fr>: Recipient address rejected: User
unknown

Email : su*********@aol.com
Errors : 2
Reason : 550 <su*********@aol.com>... User unknown

Email : sy***********@infonie.fr
Errors : 64
Reason : 552 RCPT TO:<sy***********@infonie.fr> Mailbox disk quota exceeded

Email : c.****@cario.fr
Errors : 2
Reason : 550 <c.****@cario.fr> ... recipient rejected

Email : ho**********@club-internet.fr
Errors : 8
Reason : 550 <ho**********@club-internet.fr>: Recipient address rejected:
User unknown in local recipient table
Mar 22 '06 #3
The ultimate goal is to clean up my database of undeliverable mails.

"Nico" <fa*****@free.fr> a écrit dans le message de news:
44***********************@news.free.fr...

"ZeldorBlat" <ze********@gmail.com> a écrit dans le message de news:
11**********************@g10g2000cwb.googlegroups. com...
What does the .txt file look like? (Please don't say HTML)

Well it looks like that :
Email : bo*********@wanadoo.fr
Errors : 3
Reason : 550 <bo*********@wanadoo.fr>: Recipient address rejected: User
unknown

Email : su*********@aol.com
Errors : 2
Reason : 550 <su*********@aol.com>... User unknown

Email : sy***********@infonie.fr
Errors : 64
Reason : 552 RCPT TO:<sy***********@infonie.fr> Mailbox disk quota
exceeded

Email : c.****@cario.fr
Errors : 2
Reason : 550 <c.****@cario.fr> ... recipient rejected

Email : ho**********@club-internet.fr
Errors : 8
Reason : 550 <ho**********@club-internet.fr>: Recipient address rejected:
User unknown in local recipient table

Mar 22 '06 #4

Nico wrote:
"ZeldorBlat" <ze********@gmail.com> a écrit dans le message de news:
11**********************@g10g2000cwb.googlegroups. com...
What does the .txt file look like? (Please don't say HTML)

Well it looks like that :
Email : bo*********@wanadoo.fr
Errors : 3
Reason : 550 <bo*********@wanadoo.fr>: Recipient address rejected: User
unknown

Email : su*********@aol.com
Errors : 2
Reason : 550 <su*********@aol.com>... User unknown

Email : sy***********@infonie.fr
Errors : 64
Reason : 552 RCPT TO:<sy***********@infonie.fr> Mailbox disk quota exceeded

Email : c.****@cario.fr
Errors : 2
Reason : 550 <c.****@cario.fr> ... recipient rejected

Email : ho**********@club-internet.fr
Errors : 8
Reason : 550 <ho**********@club-internet.fr>: Recipient address rejected:
User unknown in local recipient table


If you're confident about the format of the file, you can just do
something like this:

$fn = 'myfile.php';
$lines = file($fn);

$badAddresses = array();

foreach($lines as $line)
if(strpos($line, 'Email : ') === 0)
$badAddresses[] = substr($line, 8);

Of course that isn't very forgiving if one of the lines looks
different, but it should work nonetheless.

Mar 22 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Chuck Anderson | last post by:
Can anyone point me in the right direction? I want to use Php to automate confirmation of someone joining an email list by them replying to an email (so they don't have to have a browser?). I...
117
by: Steevo | last post by:
Any suggestions as to the best programs for cloaking email addresses? Many thanks -- Steevo
5
by: stemc © | last post by:
Hi there, In work, we often mail merge letters and post them to contacts. But more and more, we've been emailing information to people instead. So far, I've been writing a single generic...
2
by: .Net Newbie | last post by:
Hello, I am currently coding my ASP.Net pages in c# and have run into a question concerning Emails. I have four objects on a page (six including 2 buttons). The first is a subject line...
1
by: divya | last post by:
I have a form which has a textarea,name - txtTo where he adds email addresses.Now when he clicks on sendemail I want to open a mailto link with addresses taken from textarea. Example I added...
4
by: Jens | last post by:
Hello, We have several cases where an email, send with the CDO.Message object in ASP, is received malformed at the receiver's e-mail address. code in it. When the message is received at the...
1
by: sxwend | last post by:
I am trying to use the following post results (http://www.thescripts.com/forum/thread189759.html) and add another requirement. I need to send the results to just the email addresses that the query...
45
by: Dennis | last post by:
Hi, I have a text file that contents a list of email addresses like this: "foo@yahoo.com" "tom@hotmail.com" "jerry@gmail.com" "tommy@apple.com" I like to
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.