How to send mails through php script?

前端 未结 8 997
半阙折子戏
半阙折子戏 2021-01-01 08:02

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++)
           


        
相关标签:
8条回答
  • 2021-01-01 08:08

    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/

    0 讨论(0)
  • 2021-01-01 08:09

    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.

    0 讨论(0)
  • 2021-01-01 08:10

    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.

    0 讨论(0)
  • 2021-01-01 08:15

    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.

    0 讨论(0)
  • 2021-01-01 08:18

    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.

    0 讨论(0)
  • 2021-01-01 08:21

    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.

    0 讨论(0)
提交回复
热议问题