2016-08-12 183 views
1

我有一個帶有inmotion託管的VPS,並且我發送了一封確認郵件,但是它發送的郵件太多了,當我發送郵件時,如何構建html代碼的最佳方式,如何我可以提高表現嗎?PHP郵件發送速度很慢

這是我的代碼。

$subject = 'Mail activation'; 

$body = ' 
    <html> 
     <head> 
      <base target="_blank"> 
     </head> 
     <body> 
      <table style="max-width:800px; margin:0 auto; font-family: Arial, Helvetica, sans-serif;" cellspacing="0" cellpadding="10"> 
       <thead style="border-bottom:1px solid #DDD;"> 
        <tr> 
         <td align="center" style="border-bottom:1px solid #DDD;"> 
          <img src="http://p.unid.com/img/logoSASENegro.png" alt="" height="45" width="150"/> 
         </td> 
        </tr> 
       </thead> 
       <tbody> 
        <tr> 
         <td> 
          Hi classmate 
         </td> 
        </tr> 
        <tr> 
         <td> 
          Press the following link. 
         </td> 
        </tr> 
        <tr> 
         <td> 
          www.google.com 
         </td> 
        </tr> 
        <tr> 
         <td> 
          You data: 
         </td> 
        </tr> 
        <tr> 
         <td> 
          ID - <b>'.$ids.'</b><br/> 
          Password - <b>'.$pass.'</b><br/> 
         </td> 
        </tr> 
        <tr> 
         <td> 
          Don't response this email. 
         </td> 
        </tr> 
       </tbody> 
      </table> 
     </body> 
    </html> 
'; 

$headers = "MIME-Version: 1.0\r\n"; 
$headers .="Content-type: text/html; charset=utf-8\r\n"; 
$headers .= "From: Contacto SASE <[email protected]>\r\n"; 

if(mail($emailC, $subject, $body, $headers)) 
+0

您的語法錯誤。看看'不要回復這封電子郵件'。你的字符串在那裏結束 – Joshua

+1

性能與服務器/ MTA設置有關,而不是代碼。 (→關題)。考慮一個郵件類和一個適當的SMTP中繼。 – mario

回答

0

在某些服務器上,郵件()發送的郵件確實很慢。您的問題與郵件內容無關,但與您的託管服務提供商有關。作爲一種可能的解決方案,您可以將腳本切換爲通過不同的SMTP服務器發送郵件(例如gmail:Send email using the GMail SMTP server from a PHP page)。