如何通过php脚本发送邮件? [英] How to send mails through php script?

查看:139
本文介绍了如何通过php脚本发送邮件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何通过php脚本发送邮件?
我正在尝试这样做:

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++)
    {
        if($y->item($k)->nodeValue==$JobNoArr[$l] && $AcceptanceDateArr[$l]=='0000-00-00')
        {   
            //echo  $v->item($k)->nodeValue ;
            $email = $v->item($k)->nodeValue . ",";
            $to = $email;
            $subject = "My subject";
            $txt = "Hello world!";
            $headers = "From: webmaster@example.com" . "\r\n" .
            "CC: someother.valid@email.adr";
            mail($to,$subject,$txt,$headers);
        }
    }
}

请在此问题帮助我

最佳
Zeeshan

Best Zeeshan

推荐答案

我强烈建议使用PHP的 mail()函数发送邮件。撰写有效的电子邮件并成功交付成功比起乍看起来更棘手。有编码,把零件放在一起,验证&卫生,错误报告(超过 bool mail(...)),支持身份验证和on ... on mail()函数不提供任何这些东西。

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.

尝试 SwiftMailer 或类似的。您可以将其配置为使用PHP的 mail()函数等等。我非常推荐它。

Try SwiftMailer or similar. You can configure it to use PHP's mail() function and so much more. I highly recommend it.

这篇关于如何通过php脚本发送邮件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆