Page 1 of 1

Why this SEND EMAIL is not working?

Posted: Mon Sep 03, 2007 9:25 am
by lisawebs
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


I have a set of codes to manage a simple mail list,
everything's fine, except for this piece to send an email to each address,
I can't figure out why this is not working,
it doesn't give an error, but the no emails are sent

Code: Select all

<html><head><title>sending....</title></head><body>
<?
$addresses = file("data/lista.lst");
for ($index=0; $index < count($addresses); $index++)
{    
     $Email = "$addresses[$index]";
     mail("$Email","Welcome...","text here","From: IN21\nReply-To: alex@usa21.net");
}
?>
Your message was sent!
<br><br><a href="index.php3">Home</a>.
</body></html>
the file lista.lst has only this inside:
alexvvv@hotmail.com|lisawebs@yahoo.com|


the whole thing is in usa21.net/maillist
thanks!

lisawebs@yahoo.com


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Mon Sep 03, 2007 11:41 am
by Chris Corbyn
Use trim() to remove the end-of-line sequence from each address. Also check the return value of mail() so you know whether the server says it sent or not.

How

Posted: Mon Sep 03, 2007 5:17 pm
by lisawebs
thanks! how could I get the mail() response from server???????

Same

Posted: Mon Sep 03, 2007 5:34 pm
by lisawebs
when using explode,
the echo() shows Array, not the content,
either with "" or without
when using $addresses = File(...
the echo shows the content,

how could I test the mail() to know if the server
sent the msg?

Re: Same

Posted: Mon Sep 03, 2007 5:47 pm
by Chris Corbyn
lisawebs wrote:when using explode,
the echo() shows Array, not the content,
either with "" or without
when using $addresses = File(...
the echo shows the content
explode() returns an array so you have to loop over its elements like you were doing with file().
lisawebs wrote:how could I test the mail() to know if the server
sent the msg?

Code: Select all

//instead of just
mail( .... );

//..do this
if (mail( ... )) {
   echo "sent";
} else {
  echo "not sent";
}

Almost done...

Posted: Tue Sep 04, 2007 5:52 pm
by lisawebs
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Main solution was using  the trim()

The only problem with this code is  
the @hotmail.com addresses are not receiving emails
(not even as junk)
Yahoo and other mails are receiving normaly

So I'll open a new issue about how to control the 
mail() info/headers  to allow messages be accepted.
Thanks to everyone!!!

Code: Select all

<?
$addresses = file("data/lista.lst");
for ($index=0; $index < count($addresses); $index++)
{    
$subject    = 'the subject';
$message = 'hello';
$headers  = 'From: lisawebs@yahoo.com' . "\r\n" .
           'Reply-To: lisawebs@yahoo.com' . "\r\n"; 
if (mail(trim($addresses[$index]), $subject, $message, $headers))
    echo "yes";  
else
    echo "no";  
}

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]