0

下面的代码将通过电子邮件发送到下面的帐户,但是当我在服务器上运行它时,发送电子邮件没有任何动作,代码也没有错误,感谢您的帮助。

<?php
    $to = "chivycambpp@gmail.com";
    $subject = "Test mail";
    $message = "Hello! This is a simple email message.";
    $from = "chivycambhm@hotmail.com";
    $headers = "From:" . $from;
    mail($to,$subject,$message,$headers);
    echo "Mail Sent.";
?>
4

2 回答 2

0

试试这个

<?php 
   /* Setup your Subject and Message Body */ 
   $subject='Testing php Email'; 
   $body=' Put Your Text Message Here.'; 

  /* Specify your SMTP Server, Port and Valid From Address */ 
  ini_set("SMTP","mail.yourdomain.com"); 
  ini_set("smtp_port","25"); 
  ini_set("sendmail_from","fromYou@yourdomain.com"); 

  /* Additional Headers */ 
  $headers = "Cc:Real CC Name <ccUser@theirdomain.com>\r\n"; 
  $headers .= "Bcc:Real BCC Name <bccUser@theirdomain.com>\r\n"; 

  /* Try to send message and respond if it sends or fails. */ 
 if(mail ('ToPersonsName <toPerson@theirdomain.com>', $subject, $body, $headers )){ 
     echo "<h2>Your Message was sent!</h2>"; 
 } 
else{ 
     echo "<font color='red'><h2>Your Message Was Not Sent!</h2></font>"; 
} 
exit; 
?>
于 2013-03-16T04:30:44.760 回答
0
$toEmail="your email";
$sub="your subject";
$to=$toEmail;
$subject=$sub;
$from="info@mypropick.com"; 
$headers = "MIME-Version: 1.0\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\n";
$headers .= "From: <".$from.">\n";
$headers .= "X-Priority: 1\n";
$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 ))
echo "Mail Sent Successfully";
else
echo "Mail is not sent please set your smtp setting";   
于 2013-03-16T04:54:33.323 回答