使用php从Hotmail发送电子邮件 [英] Send email from Hotmail using php

查看:163
本文介绍了使用php从Hotmail发送电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要使用php发送电子邮件。这是我的代码:

  $ to =dear-angel@hotmail.fr; 
$ subject =需求干预;
$ message =< h1> Demande d'intervention< h1>
Bonjour,< br>
il y a une urgence et on souhaite votre intervention docteur< br>
$ headers ='From:DRIF< dear-angel@hotmail.fr>'。 \\\\。
'Reply-To:dear-angel@hotmail.fr'。 \\\\。
'Content-Type:text / html; charset =iso-8859-1'。 \\\\。
'X-Mailer:PHP /'。 phpversion();

mail($ to,$ subject,$ message,$ headers);

这是我如何配置php.ini文件:

  [邮件功能] 

;仅适用于Win32
; http://php.net/smtp
SMTP =smtp.live.com
; http://php.net/smtp-port
smtp_port = 587
username =dear-angel@hotmail.fr
password =blablabla
;仅适用于Win32
; http://php.net/sendmail-from
sendmail_from =dear-angel@hotmail.fr

我收到此错误消息:

  SMTP服务器响应:550 5.7.3请求的操作中止;用户未认证

我尝试连接到我的hotmail帐户,但是我没有找到最近的活动我可以确认这是我。
我听说我必须使用php邮件程序,但我不知道如何使用它



你能帮助我吗?感谢提前

解决方案

简单的答案是你做错了。直接调用 mail()几乎总是一个错误。构建和发送电子邮件真的很难做到正确,所以使用像 PHPMailer 这样的图书馆为你做。



Windows上常见的问题是您通常没有本地邮件服务器,因此邮件功能根本不起作用。一些库(包括PHPMailer)包含一个SMTP客户端,可以直接发送消息而不需要本地邮件服务器。这不总是一个好主意,因为SMTP不利于交互式使用(例如在HTML页面加载期间),但可能是您可以使用的。



Windows部署堆栈如 WAMP 提供自己的邮件服务器。



您会发现PHPMailer提供的很多示例 - 只需更改其设置即可使用您的配置。如果你陷入困境,那么有很多文档,自述文件,帮助wiki和生成的API文档,以及这里的大量问题和答案(看看PHPMailer标签)。


I need to send an email using php. here's my code :

                $to= "dear-angel@hotmail.fr";
                $subject = "demande d'intervention";
                $message = "<h1>Demande d'intervention<h1>
                Bonjour,<br>
                il y a une urgence et on souhaite votre intervention docteur <br>";
                $headers = 'From: DRIF <dear-angel@hotmail.fr>' . "\r\n" .
                    'Reply-To: dear-angel@hotmail.fr' . "\r\n" .
                    'Content-Type: text/html; charset="iso-8859-1"' . "\r\n" .
                    'X-Mailer: PHP/' . phpversion();

                mail($to, $subject, $message, $headers);

this is how I configured php.ini file:

[mail function]

; For Win32 only.
; http://php.net/smtp
SMTP = "smtp.live.com"
; http://php.net/smtp-port
smtp_port = 587
username="dear-angel@hotmail.fr"
password="blablabla"
; For Win32 only.
; http://php.net/sendmail-from
sendmail_from = "dear-angel@hotmail.fr"

I get this error message :

SMTP server response: 550 5.7.3 Requested action aborted; user not authenticated

I tried to connect to my hotmail account but I didn't find any recent activities so I can confirm that it was me. I heard that I have to use php mailer but I didn't know how to use it

Can you please help me? thanks in advance

解决方案

The simple answer is "you're doing it wrong". Calling mail() directly is almost always a mistake. Constructing and sending emails is really quite difficult to do correctly, so use a library like PHPMailer to do it for you.

The usual problem on Windows is that you don't usually have a local mail server, so the mail function doesn't work at all. Some libraries (PHPMailer included) contain an SMTP client that can send messages directly without needing a local mail server. This is not always a good idea as SMTP is not good for interactive use (e.g. during an HTML page load), but it may be all you can use.

Windows deployment stacks like WAMP provide their own mail server.

You will find plenty of examples provided with PHPMailer - just change their settings to work with your configuration. If you get stuck, there are lots of docs, the readme, the help wiki and generated API documentation, plus a ton of questions and answers here on SO (look under the PHPMailer tag).

这篇关于使用php从Hotmail发送电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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