doujuanxun7167 2017-07-16 05:40
浏览 15

无法通过电子邮件发送详细信息[重复]

This question already has an answer here:

$sql = "insert into book (uid,interest,tid,lid)values('$id','$interest','$tid','$lid') ";
$result = $conn->query($sql);
if($result)
{
    echo"<script type='text/javascript'>
    alert('added');
    </script>";
    
$message = "Your have interest in ".$interest."";
$to=$email;
$subject="Booked for ".$title."";
$from = 'vkcvkc8@gmail.com';
$body="Booked for ".$title."located in".$location.".You will be charged with".$cost.
        ".Contact:".$contact."";
$headers = "From:".$from;
mail($to,$subject,$body,$headers);


}
else
    {
    echo"<script type='text/javascript'>
    alert('error');
    </script>"; 
}
    

not sending email not sending emailnot sending emailnot sending emailnot sending emailnot sending emailnot sending email?????

</div>
  • 写回答

2条回答 默认 最新

  • douyue8685 2017-07-16 05:53
    关注

    You have to use smtp settings to be able to send the mail as most hosting providers now have closing the php mail function due to security reasons, this is the script for a proper smtp mail function and dont use third party tools like php mailer just ask your hosting provider to activate mail function in pear packages

    <?php
    require_once "Mail.php"; 
    $from = "Web Master <webmaster@example.com>"; 
    $to = "Nobody <nobody@example.com>";
    $subject = "Test email using PHP SMTP
    
    ";
    $body = "This is a test email message";
    $host = "SMTPhostname"; 
    $username = "webmaster@example.com"; 
    $password = "yourPassword"; 
    $headers = array ('From' => $from, 'To' => $to, 'Subject' => $subject); 
    $smtp = Mail::factory('smtp', array ('host' => $host, 'auth' => true, 'username' => $username, 'password' => $password)); $mail = $smtp->send($to, $headers, $body); 
    if (PEAR::isError($mail)) { 
    echo("<p>" . $mail->getMessage() . "</p>"); }
    else
     { echo("<p>Message successfully sent!</p>"); 
    } 
    ?>
    
    评论

报告相同问题?

悬赏问题

  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目
  • ¥20 mysql架构,按照姓名分表
  • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分
  • ¥15 delphi webbrowser组件网页下拉菜单自动选择问题
  • ¥15 linux驱动,linux应用,多线程