2011-05-11 18 views
0

是否有像aspSmarMail這樣的郵件對象,我可以從PHP腳本調用指定'服務器','senderaddress','收件人'等子屬性的郵件對象?例如,在MS的視覺Foxpro9我可以使用此代碼:用於PHP的aspSmartMail對象

loIP = CREATEOBJECT("aspSmartMail.SmartMail") 
loIP.server = "mailout.my.domain.com" 
loIP.SenderName = "Emailer" 
loIP.SenderAddress = "[email protected]" 
loIP.Recipients.Add("[email protected]") 
loIP.Subject = "Emailer Subject" 
loIP.ContentType = "text/html" 
loIP.Charset = "us-ascii" 
loIP.Body = "This is the body of the email" 
loIP.SendMail() 

基本上這將中繼生成的電子郵件以「mailout.my.domain.com」郵件服務器和它將被代替送出具有的那種方式在我的本地主機上安裝一個SMTP MTA。

是否有一些語法允許我這樣做?

回答

1

可以從PHP腳本中指定的「服務器」,「senderaddress」,「收件人」,等叫子屬性

雖然這是種可能使PHP的內置mail函數與一個arbritary SMTP服務器進行通信,這樣做是很困難的。在PHP中使用SMTP服務器的最佳方式是使用第三方郵件庫。

SwiftMailer強烈建議在這些部分,但PHPMailer和PEAR的Mail包也能夠直接與SMTP服務器進行通信。

檢出SwiftMailer's documentation on sending via SMTPthe way it assembles messages快速howto。

+0

SwiftMailer是正是我需要的,它完全固定我的問題,請參閱此鏈接以查看有關此問題的完整原始帖子。 http://stackoverflow.com/questions/5869705/php5-mail-function-sendmail-error – sadmicrowave 2011-05-12 18:11:50