【问题标题】:Cant get xammp to send email through PHP无法让 xampp 通过 PHP 发送电子邮件
【发布时间】: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 ,这似乎不起作用。我完全迷路了。一些方向,一个教程,任何你能提供的东西都请大家!

【问题讨论】:

    标签: php gmail xampp


    【解决方案1】:

    在 Linux 系统上,邮件是通过使用 Sendmail 的 mail() 函数从 PHP 发送的。每当我在 Windows 上使用 Swiftmailer 时,我都会使用 SMTP,这是 gmail 允许的。

    http://www.swiftmailer.org/wikidocs/v3/smtpauth

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-09-12
      • 2013-03-30
      • 2016-10-29
      相关资源
      最近更新 更多