Mail funtion question

This is a discussion on Mail funtion question within the PHP General forums, part of the PHP Programming Forums category; I am using the PHP mail() function to send subscribed-to bulk email. It successfully sends emails to the valid ...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 07-29-2003
Irvin Amoraal
 
Posts: n/a
Default Mail funtion question

I am using the PHP mail() function to send subscribed-to bulk email. It
successfully sends emails to the valid email addresses, but I get a series
of error messages at the top of the PHP page like:
/home/[my folder]/dead.letter... Saved message in
/home/[my folder]/dead.letter 123... User unknown

I'm almost positive the error msgs are caused by invalid email addresses
that are stored in the database.

I have two questions:
1. How can I suppress the error msg's? @mail....?
2. Can the error be trapped and the invalid email address captured to be
spit out in code?

Thanks for your help.

Irvin.


Reply With Quote
  #2 (permalink)  
Old 07-30-2003
Bobby Patel
 
Posts: n/a
Default Re: Mail funtion question

I haven't worked with PHP mail for a while, but since no one has responded
I'll give you something to consider:

1. Why don't you try error suppression , @ ? or you can set error_reporting
down or you can capture all output by using output buffering.
2. You can trap the invalid email, but it may be *more* complex and result
in a slower script. You will have to evaluate this for yourself,

$emails = array (); #array of email info
# In the form
# $emails[0] = array (email => mailto:'abc@abc.com' , name => 'Reciever
Name');
# $emails[1] = array (email => mailto:'abc@xyz.com' , name => 'Reciever Name
2');

$invalid_emails = array();
foreach ($emails as $index => $info){

$result = @mail ($info['email'], 'Bulk Newsletter Subject', 'email
messafge') ;
if (!$result) {
$invalid_emails [] = $info['email']; // capture invalid email
}
}

Please note, that the code above will call mail once for each email, so if
you have 100 emails this will run 100 times, where as if you stacked all the
emails into one mail call. But then you may not be able to find the invalid
emails.




"Irvin Amoraal" <irvin@cabletv.on.ca> wrote in message
news:20030729214615.15280.qmail@pb1.pair.com...
> I am using the PHP mail() function to send subscribed-to bulk email. It
> successfully sends emails to the valid email addresses, but I get a series
> of error messages at the top of the PHP page like:
> /home/[my folder]/dead.letter... Saved message in
> /home/[my folder]/dead.letter 123... User unknown
>
> I'm almost positive the error msgs are caused by invalid email addresses
> that are stored in the database.
>
> I have two questions:
> 1. How can I suppress the error msg's? @mail....?
> 2. Can the error be trapped and the invalid email address captured to be
> spit out in code?
>
> Thanks for your help.
>
> Irvin.
>
>



Reply With Quote
  #3 (permalink)  
Old 07-30-2003
Irvin Amoraal
 
Posts: n/a
Default Re: Mail funtion question

Thanks for your reply Bobby.
I thought I might be able to use the @ to supress the errors. The way you
wrote the code below is close to what I am doing, sending the bulk emails
one at a time. I didn't see anything like $result= @mail($to, $subject,
$msg) in the online PHP documentation. but it looks like it should do the
trick.

Thanks again.

"Bobby Patel" <anup_patel@rogers.com> wrote in message
news:20030730033028.97292.qmail@pb1.pair.com...
> I haven't worked with PHP mail for a while, but since no one has responded
> I'll give you something to consider:
>
> 1. Why don't you try error suppression , @ ? or you can set

error_reporting
> down or you can capture all output by using output buffering.
> 2. You can trap the invalid email, but it may be *more* complex and result
> in a slower script. You will have to evaluate this for yourself,
>
> $emails = array (); #array of email info
> # In the form
> # $emails[0] = array (email => mailto:'abc@abc.com' , name => 'Reciever
> Name');
> # $emails[1] = array (email => mailto:'abc@xyz.com' , name => 'Reciever

Name
> 2');
>
> $invalid_emails = array();
> foreach ($emails as $index => $info){
>
> $result = @mail ($info['email'], 'Bulk Newsletter Subject', 'email
> messafge') ;
> if (!$result) {
> $invalid_emails [] = $info['email']; // capture invalid email
> }
> }
>
> Please note, that the code above will call mail once for each email, so if
> you have 100 emails this will run 100 times, where as if you stacked all

the
> emails into one mail call. But then you may not be able to find the

invalid
> emails.
>
>
>
>
> "Irvin Amoraal" <irvin@cabletv.on.ca> wrote in message
> news:20030729214615.15280.qmail@pb1.pair.com...
> > I am using the PHP mail() function to send subscribed-to bulk email. It
> > successfully sends emails to the valid email addresses, but I get a

series
> > of error messages at the top of the PHP page like:
> > /home/[my folder]/dead.letter... Saved message in
> > /home/[my folder]/dead.letter 123... User unknown
> >
> > I'm almost positive the error msgs are caused by invalid email addresses
> > that are stored in the database.
> >
> > I have two questions:
> > 1. How can I suppress the error msg's? @mail....?
> > 2. Can the error be trapped and the invalid email address captured to be
> > spit out in code?
> >
> > Thanks for your help.
> >
> > Irvin.
> >
> >

>
>



Reply With Quote
Reply


Thread Tools
Display Modes

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 Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 08:45 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0