Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/email/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用Hiawatha上运行的cakephp向AWS SES发送邮件时出现内部服务器错误500_Php_Email_Cakephp_Amazon Web Services_Hiawatha - Fatal编程技术网

使用Hiawatha上运行的cakephp向AWS SES发送邮件时出现内部服务器错误500

使用Hiawatha上运行的cakephp向AWS SES发送邮件时出现内部服务器错误500,php,email,cakephp,amazon-web-services,hiawatha,Php,Email,Cakephp,Amazon Web Services,Hiawatha,在第三次或第一次尝试通过在Hiawatha服务器上运行的AWS SES帐户(在生产模式下)使用CakePHP 3发送邮件后,我收到了“内部服务器错误500” 以下是我的php代码: public function sendmail() { $email = new Email(); $email->transport('SES'); try { $res = $email->from(['account@example.com' =>

在第三次或第一次尝试通过在Hiawatha服务器上运行的AWS SES帐户(在生产模式下)使用CakePHP 3发送邮件后,我收到了“内部服务器错误500”

以下是我的php代码:

  public function sendmail()
{
    $email = new Email();
    $email->transport('SES');
    try {
        $res = $email->from(['account@example.com' => 'Name'])
              ->to(['receiver@hotmail.com' => 'Receiver'])
              ->subject('Test mail')
              ->send('some text');
    } catch (Exception $e) {
        $this->Flash->error('Error. Please, try again.');
        echo 'Exception : ',  $e->getMessage(), "\n";
        return $this->redirect('/');
    }
    $this->Flash->success('Ok. You will receive a confirmation mail');
    return $this->redirect('/');} 
这是传输配置

     'EmailTransport' => [
     'SES' => [
         'host' => 'email-smtp.eu-west-1.amazonaws.com',
         'port' => 25,
         'timeout' => 60,
         'username' => 'ASDFASADQWE',
         'password' => 'FSDFDSFDSFSEREWRWERWER',
         'tls' => true,
         'className' => 'Smtp'
     ],
端口465和587在第一次尝试时不工作

因此,基本上我无法确定问题是来自CakePHP、AWS SES还是服务器上的某些配置


谢谢您的推荐。

最后,我停止使用cakePHP mail并设置phpMail,在使用compose并使其运行时遇到一些困难,但最后,这是我可以连续发送多封邮件的工作代码

   public function sendMailPHPMailer()
    {
      $mail = new \PHPMailer();
      $mail->isSMTP();                                      
      $mail->Host = 'email-smtp.eu-west-1.amazonaws.com';  
      $mail->SMTPAuth = true;                              
      $mail->Username = 'username'; 
      $mail->Password = 'password';
      $mail->SMTPSecure = 'tls';    
      $mail->Port = 587;                               
      $mail->From = 'mail@mail.com';
      $mail->FromName = 'cakePHP PHPMailer';
      $mail->addAddress('tomail@mail.com', 'receiver');
      $mail->isHTML(true);                               
      $mail->Subject = 'Test using PHPMailer & SES';
      $mail->Body    = 'This is the HTML message body <b>in bold!</b>';
      $mail->AltBody = 'This is the body in plain text';

      if(!$mail->send()) {
          $this->Flash->error('error');
          echo 'Exception : ',  $mail->ErrorInfo, "\n";
          return $this->redirect('/');
        }else{
          $this->Flash->success('ok');
          return $this->redirect('/');
        }
    }
    public function sendmail()
    {
        $email = new Email();
        $email->transport('SES');
        try {
            $res = $email->from(['mail@mail.com' => 'cakePHP mail'])
                  ->to(['tomail@mail.com' => 'receiver'])
                  ->subject('cakePHP & SES')
                  ->send('message via cakePHP and SES');
        } catch (Exception $e) {
            $this->Flash->error('error');
            echo 'Exception : ',  $e->getMessage(), "\n";
            return $this->redirect('/');
        }
        $this->Flash->success('ok');
        return $this->redirect('/');
}