douzhi7661 2012-04-27 03:01
浏览 797

PHP连接到Hotmail发送邮件?

currently I am trying to use PHPmailer to send email out. Here are the codes below

<?php     
require("phpmailer/class.phpmailer.php");   
$mail = new PHPMailer();   // ---------- adjust these lines ---------------------------    ------------   
$mail->Username = "(username@hotmail.com)"; // your hotmail user name    
  $mail->Password = "password";
  $mail->AddAddress"(username@hotmail.com)"; // recipients email     
  $mail->FromName = "test"; // readable name     
  $mail->Subject = "Subject title";     
  $mail->Body    = "Here is the message you want to send to your friend.";     
  //-----------------------------------------------------------------------     
  $mail->Host = "smtp.live.com"; // GMail     
  $mail->Port = 25;     $mail->IsSMTP(); // use SMTP  
  $mail->SMTPAuth = true; // turn on SMTP authentication 
  $mail->From = $mail->Username;  
  if(!$mail->Send())     
      echo "Mailer Error: " . $mail->ErrorInfo;     
  else       
      echo "Message has been sent";     

  ?> 

I've tried SSL, port 587 for smtp.live.com with PHPMailer, why doesn't it work?

The error is "SMTP Error: Could not connect to SMTP host. Mailer Error: SMTP Error: Could not connect to SMTP host."

I cannot telnet smtp.live.com 25,587. smtp.gmail.com etc etc.. What should i do? :(

  • 写回答

3条回答 默认 最新

  • dongshang1934 2013-07-17 05:12
    关注

    port 587 worked for me.

    no need to run IsSMTP(). Comment it out as it will throw exceptions.

    Dont forget to mark it as answer if it solves your problem :)

    评论

报告相同问题?

悬赏问题

  • ¥88 实在没有想法,需要个思路
  • ¥15 MATLAB报错输入参数太多
  • ¥15 python中合并修改日期相同的CSV文件并按照修改日期的名字命名文件
  • ¥15 有赏,i卡绘世画不出
  • ¥15 如何用stata画出文献中常见的安慰剂检验图
  • ¥15 c语言链表结构体数据插入
  • ¥40 使用MATLAB解答线性代数问题
  • ¥15 COCOS的问题COCOS的问题
  • ¥15 FPGA-SRIO初始化失败
  • ¥15 MapReduce实现倒排索引失败