donglie7778 2013-03-15 04:26
浏览 49
已采纳

在PHP中发送邮件失败

I am trying to send email using mail function in php:

$subject = 'testing';
$email = 'test@gmail.com';
$message = 'test message';          
$headers  = 'MIME-Version: 1.0' . "
";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "
";
$headers .= "From: The test site" . "
";

if (mail($email, $subject, $message, $headers)) {
  $data['msg']="Message send successfully";
} 
else {
  $data['msg']="Please try again, Message could not be sent!";
}  

I Encounter following error:

A PHP Error was encountered

Severity: Warning

Message: mail() [function.mail]: SMTP server response: 501 Syntax error in parameters or arguments

Filename: sendemail.php

Line Number: 40

I might guess that error was due to not setting configuration required for sending email in php. What should I need to do or I have to change in php.ini file but it's not accesible. Any solution please?

  • 写回答

4条回答 默认 最新

  • dongyi2083 2013-03-15 04:52
    关注
    $subject = 'testing';
    $email = 'test@gmail.com';
    $message = 'test message';          
    $headers  = 'MIME-Version: 1.0' . "
    ";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "
    ";
    $headers .= "From: The test site" . "
    ";
    
    
    $to=$toEmail;
    $subject=$sub;
    $from="info@mypropick.com"; 
    $headers = "MIME-Version: 1.0
    ";
    $headers .= "Content-type: text/html; charset=iso-8859-1
    ";
    $headers .= "From: <".$from.">
    ";
    $headers .= "X-Priority: 1
    ";
    $message='<div style=" width:700px; margin:0 auto; border:1px solid #e2e2e2; padding:20px;">
    <h3>MYPROPICK Services:</h3>'.$msg.'</div>';
    $message .= "<br/>Regards <br />MYPROPICK.COM";
    
    
    if (mail($to, $subject, $message, $headers )) {
      $data['msg']="Message send successfully";
    } 
    else {
      $data['msg']="Please try again, Message could not be sent!";
    }  
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 暴力法无法解出,可能要使用dp和数学知识
  • ¥15 wpf通过绑定控件自身的值,来实现背景颜色的切换
  • ¥15 CDH6.3 运行hive -e hive -e "show databases;"报错:hive-env.sh:行24: hbase-common.jar: 权限不够
  • ¥15 SSRS制作的报表打开报错,无法正常显示网页
  • ¥15 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系