How can i send mails through the php script?? I am trying to do somthing like this:
for($k=0;$k<=$x->length-1;$k++)
{
for($l=0;$l<=$j-1;$l++)
the problem is mail function is very unreliable, especially when sending large amount of emails.
i would recommend looking into PHPmailer library (uses direct SMTP connection): http://phpmailer.codeworxtech.com/
php-s mail function uses sendmail as a MTA, so if some mails go through and some not, I would look at sendmail's log for errors.
first do
echo $result = mail($to,$subject,$txt,$headers);
and see what u get , error ?
I recommend to use a class such phpMailer
why you have comma in the end of ths line ?
$email = $v->item($k)->nodeValue . ",";
you send to one mail every time.
You're trying too much all at once. Try going one step at a time. First send a simple email, with hard-coded parameters to get that working, then troubleshoot it within the context of your nested loops.
If you are on a shared web host, or your home computer, the main domain for the server will be something like
server.your-isp-or-host.com
The spam filter will then see the email claiming to be from
yourdomain.com
when it really came from the first address, and would then delete it.
This would explain the hit-and-miss nature of your error.
If you are on a dedicated server, or a static IP pointing to your home computer with properly set up DNS, the above does not apply.
I strongly advise against sending mail using PHP's mail()
function. Composing valid emails and delivering them successfully is trickier than it seems at first glance. There is encoding, putting parts together, validation & sanitation, error reporting (more than bool mail(...)
), support for authentication and on and on ... The mail()
function does not offer any of these things.
Try SwiftMailer or similar. You can configure it to use PHP's mail()
function and so much more. I highly recommend it.