【发布时间】:2011-06-02 20:35:24
【问题描述】:
试图让我的 php 脚本发送电子邮件时遇到很大问题。在我的 Mac 上使用这个脚本:
<?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
所以我尝试了一个基本的 mail() 脚本,但它不起作用。我用过 stunnel ,这似乎不起作用。我完全迷路了。一些方向,一个教程,任何你能提供的东西都请大家!
【问题讨论】: