2011-06-02 43 views
0

有很大的問題試圖讓我的PHP腳本發送電子郵件。在我的mac上使用此腳本:不能讓xammp通過PHP發送電子郵件

<?php 

require_once 'lib/swift_required.php'; 
$image = file_get_contents("php://input"); 
$attachment = Swift_Attachment::newInstance($image, 'submission.jpg', 'image/jpg'); 

$message = Swift_Message::newInstance() 
    /*Give the message a subject*/ 
    ->setSubject('Your subject') 
    /*Set the from address with an associative array*/ 
    ->setFrom(array('email'=>'Name')) 
    /*Set the to addresses with an associative array*/ 
    ->setTo(array('email')) 
    /*Give it a body*/ 
    ->setBody('Email'); 
    $message->attach($attachment);//<--When the attachment above is commented out, so is this 

    $transport = Swift_SendmailTransport::newInstance(); 
    $mailer = Swift_Mailer::newInstance($transport); 
    $mailer->send($message); 

?> 

電子郵件發送罰款,附加圖像,是偉大的。但是,這在Windows上不起作用。我讀過Windows沒有郵件服務器,所以花了幾天的時間與hmailserver,mercury,mailsender等爭取試圖獲得電子郵件發送。 我得到一個奇怪的錯誤,從swiftmailer:

Fatal error: Uncaught exception 'Swift_TransportException' with message 'Process could not be started [The system cannot find the path specified. ]' in C:\xampp\htdocs\lib\classes\Swift\Transport\StreamBuffer.php:268 Stack trace: #0 C:\xampp\htdocs\lib\classes\Swift\Transport\StreamBuffer.php(66): Swift_Transport_StreamBuffer->_establishProcessConnection() #1 C:\xampp\htdocs\lib\classes\Swift\Transport\AbstractSmtpTransport.php(101): Swift_Transport_StreamBuffer->initialize(Array) #2 C:\xampp\htdocs\lib\classes\Swift\Transport\SendmailTransport.php(61): Swift_Transport_AbstractSmtpTransport->start() #3 C:\xampp\htdocs\lib\classes\Swift\Mailer.php(74): Swift_Transport_SendmailTransport->start() #4 C:\xampp\htdocs\Mail.php(20): Swift_Mailer->send(Object(Swift_Message)) #5 {main} thrown in C:\xampp\htdocs\lib\classes\Swift\Transport\StreamBuffer.php on line 268 

所以我嘗試了基本的郵件()腳本,並且不工作。我用過stunnel,但似乎不起作用。我完全失去了。一些方向,教程,任何你可以提供的請傢伙!

回答