php
  • jquery
  • email
  • 2016-02-13 19 views -1 likes 
    -1

    我有一个HTML格式的信息被发送到这个脚本,除了发送的电子邮件之外,一切都正常工作......它似乎发送(如果语句经过)。但我没有收到任何东西。前几天我收到了电子邮件,其中所有数据都是“Array []”,但现在由于某种原因,它不起作用。PHP电子邮件未被发送,出了什么问题?

    <?php 
    echo "<link href='https://fonts.googleapis.com/css?family=Montserrat:400,700' rel='stylesheet' type='text/css'>"; 
    
    if (!empty($_POST) && $_POST['email-address'] != null) 
    { 
        $inquireType = $_POST['inquiry-type']; 
        $firstName = $_POST['first-name']; 
        $lastName = $_POST['last-name']; 
        $email = $_POST['email-address']; 
        $businessName = $_POST['business-name']; 
        $information = $_POST['extra-information']; 
    
        $message = "" . $inquireType . ' INQUIRIE FROM: ' . $firstName . ' ' . $lastName . "\r\n" . 
         'Email: ' . $email . "\r\n" . 
         'Business Name: ' . $businessName . "\r\n" . 
         'Additional Information: ' . $information; 
    
        $headers = "From: " . strip_tags($_POST['email-address']) . "\r\n"; 
        $headers .= "Reply-To: ". strip_tags($_POST['email-address']) . "\r\n"; 
        $headers .= "CC: [email protected]\r\n"; 
        $headers .= "MIME-Version: 1.0\r\n"; 
    
        mail('[email protected]', "Inquirie", $message, $headers); 
    
        if (mail('[email protected]', 'Inquirie From ' . $firstName, $message, $headers)) 
        { 
         echo "<div style='position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: green;'><br><br><p align='center'><font size='5rem' face='Montserrat' color='white'>Inquiry Successfully Sent! Expect a reply from me shortly."; 
        } 
        else { 
         echo "<div style='position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: red;'><br><br><p align='center'><font size='5rem' face='Montserrat' color='white'>Inquiry Not Sent, something must have went wrong..."; 
        } 
    } 
    else { 
        echo "<div style='position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: darkred;'><br><br><p align='center'><font size='5rem' face='Montserrat' color='white'>Inquiry Not Sent, something must have went wrong..."; 
    } 
    
    ?> 
    
    +0

    您是否检查过垃圾邮件文件夹? – Samir

    +0

    您得到询问不发送,一定有错误? – devpro

    +0

    我经常检查我的垃圾邮件文件夹,不,它显示电子邮件正在通过... – BudBroesky

    回答

    0

    变量$headers是一个字符串,您使用implode("\r\n", $headers)同时发送电子邮件。这会发出警告。

    implode("\r\n", $headers)替换为$headers,因为您在准备标题字符串时已经连接\r\n

    +0

    我忘了改变这一点,看到我发布,但它仍然没有发送甚至没有内爆... – BudBroesky

    0

    我认为这是因为您没有提供电子邮件帐户的凭据。我在我的应用程序中使用了下面的代码(使用C#)。我希望它可以帮助你。

      //Configure an SmtpClient to send the mail. 
          SmtpClient client = new SmtpClient("smtp.gmail.com", 587); 
          client.EnableSsl = true; //only enable this if your provider requires it 
          //Setup credentials to login to our sender email address ("UserName", "Password") 
          NetworkCredential credentials = new NetworkCredential("[email protected]", "mypassword"); 
          client.Credentials = credentials; 
    
    相关问题