2014-05-04 44 views
0

我已經創建了一個程序用於發送電子郵件與自定義html格式與一些用戶的日期和一些預先寫好的文字。PHP電子郵件模板沒有發送

該郵件不會被髮送,我不知道爲什麼。這裏是代碼:

$to = $_SESSION['email']; 
          $subject = 'Possword recovery'; 
          $message = '<table border="0" cellpadding="0" cellspacing="0" width="100%"> 
           <tr> 
            <td> 
             <table border="0" cellpadding="0" cellspacing="0" style="width:800px; background-color:#EEE; border:solid 1px #DDD; padding:10px;" align="center"> 
              <thead> 
               <tr> 
                <td style="padding:10px; vertical-align:middle; height:150px; background-color:#00247D; width:60%;"> 
                 <img src="http://www.welovegreatbritain.com/email/images/logo.png"> 
                </td> 
                <td style="vertical-align:middle; background-color:#900; width:40%; color:#FFF; font-family:Arial, Helvetica, sans-serif;"> 
                 <span style="font-size:12px; margin-left:30px; display:block; text-decoration:underline;">Contact Us </span> 
                 <span style="font-size:10px; margin-left:30px; display:block; margin-top:4px;">0844-414-8582</span> 
                 <span style="font-size:10px; margin-left:30px; display:block; margin-top:1px;">0871-288-5127</span> 
                 <p style="margin-left:30px; margin-right:15px;"> 
                  <b style="font-size:12px;">NOTE : </b> 
                  <span style="font-size:10px;"> If you are calling from outside UK please dial 0044 0844 414 8582 or 0044 0844 288 5127</span> 
                 </p> 
                </td> 
               </tr> 
              </thead> 
              <tbody> 
               <tr> 
                <td colspan="2" style="background-color:#FFF; height:600px; padding:10px; vertical-align:top; font-family:Arial, Helvetica, sans-serif;"> 
                 <h2 style="font-weight:normal; font-size:17px; color:#00247D; margin-top:25px; margin-left:25px;">Password Recovery</h2> 
                 <p style="margin-left:25px; font-size:16px;"> 
                  Hi, we just notice that you have attampted a password recovery from the below location. 
                  <span style="display:block; font-size:12px; margin-top:10px;">Country : <span style="margin-left:25px;">'.$country.'</span></span> 
                  <span style="display:block; font-size:12px;">City : <span style="margin-left:47px;">'.$client_city.'</span></span> 
                  <span style="display:block; font-size:12px;">Browser : <span style="margin-left:21px;">'.$browser.'</span></span> 
                  <span style="display:block; font-size:12px;">OS : <span style="margin-left:50px;">'.$os.'?></span></span> 
                  <span style="display:block; font-size:12px;">IP : <span style="margin-left:55px;">'.$client_ip.'</span></span> 
                 </p> 
                 <p style="margin-left:25px; margin-top:50px;"> 
                  <span style="font-size:25px;"> 
                   Cancer Research UK 
                  </span> 
                 </p> 
                 <p style="margin-left:25px;"> 
                  Join our 10 minute surevy and save a life. <a href="#">Click Here</a> to join now. 
                  <span style="display:block;"> 
                   Nothing is complecate on this surevy. You just have to answer 10 simple qustions and can save a life. 
                  </span> 
                 </p> 
                 <p style="margin-left:25px; margin-top:60px;"> 
                  Thanks 
                  <span style="display:block">James Cosgrove</span> 
                 </p> 
                </td> 
               </tr>     
              </tbody> 
              <tfoot> 
               <tr> 
                <td style="vertical-align:top; padding:5px 0 0 0; color:#666; font-size:12px; border-top:solid 1px #DDD;"> 
                 <span>Maximum SRJ | </span> &copy; 2014 
                 <span style="display:block; font-size:12px;"> 
                  Director : James Cosgrove 
                 </span> 
                 <span style="display:block; font-size:12px;"> 
                  Email : [email protected] 
                 </span> 
                 <span style="display:block;font-size:12px;"> 
                  Address : BT Street, London, 401523, UK 
                 </span> 
                 <span> 
                  <a href="#">Terms & Condition</a> 
                 </span> 
                 <span style="color:#000; font-weight:bold">|</span> 
                 <span> 
                  <a href="#">Privacy</a> 
                 </span> 
                 <span style="color:#000; font-weight:bold">|</span> 
                 <span> 
                  All Rights Reserved 
                 </span> 
                </td> 
                <td style="padding:0 0 0 0; vertical-align:top; text-align:right; border-top:solid 1px #DDD;"> 
                 <img src="http://www.welovegreatbritain.com/email/images/flogo.png" style="margin-top:5px;" /> 
                </td> 
               </tr> 
              </tfoot> 
             </table> 
            </td> 
           </tr> 
          </table> 
          '; 

          $headers = 'MIME-Version: 1.0' . "\r\n"; 
          $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; 
          $headers .= 'From: Welove Great Britain <[email protected]>' . "\r\n";  
          mail($to, $subject, $message, $headers); 

此外它沒有顯示任何類型的錯誤消息。與此頁面相關的其他功能就像將某個用戶日期存儲到mysql表中一樣正常工作。

所以,任何人請幫助我解決這些麻煩。我會非常感謝你。

+1

首先嚐試檢查一些零件是否工作。然後逐步調試。 –

+1

'session_start();'加載?你的電子郵件是基於會話。 –

+0

其中是session_start(); ?它應該在第一行。 –

回答

0

嘗試在php.ini中啓用擴展。 Maby SMTP概述了「;」標誌。

+0

Hin @ Tyga21,我認爲你的解決方案會工作。但如何編輯我的託管php.ini? –