[TYPO3-german] sendMail

arianesardinas asardinas at gmx.de
Sat Dec 21 16:01:12 CET 2013


Hallo

ich habe eine merkwürdiges verhalten eine email versand. und zwar habe ich in Controller eine function sendMail wie hier beschrieben, gebaut:

https://lbrmedia.net/codebase/Eintrag/extbase-60-sendmail/
von meine  testAction rufe ich die methode sendMail()

es sieht so aus:
public function testAction(){

$to='meine (at) gmx.de';
$subject='test';
$html='fsdfdsfds';
$fromEmail='from (at) gmx.de';
$fromName='test';
$replyToEmail='';
$replyToName='';
$plain='fsdfdsfds';
		
$this->meineEmail($to, $subject, $html, $plain, $fromEmail = '', $fromName = '', $replyToEmail = '', $replyToName = '', $returnPath = '', $attachements = array());

}
leider bekomme ich kein Fehler aber die emails kommen nicht an, bzw gehen nicht raus.
Alles was in der sendMail Methode ist richtig weil wenn ich den code in der testAction kopiere funktioniert es.

Also wenn testAction so aussieht:

public function testAction(){ 

$to='meine (at) gmx.de';
$subject='test';
$html='fsdfdsfds';
$fromEmail='from (at) gmx.de';
$fromName='test';
$replyToEmail='';
$replyToName='';
$plain='fsdfdsfds';

 // make instance of swiftmailer
  $message = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Mail\\MailMessage');
   
  // from
  if ($fromEmail) {
    $message->setFrom(array($fromEmail => $fromName));
  }
 
  // to
  $recipients = array();
  if (is_array($to)) {
    foreach ($to as $pair) {
      if (\TYPO3\CMS\Core\Utility\GeneralUtility::validEmail($pair['email'], false)) {
        if (trim($pair['name'])) {
          $recipients[$pair['email']] = $pair['name'];
        } else {
          $recipients[] = $pair['email'];
        }
      }
    }
  } else {
    $recipients[] = $to;
  }
 
  if (!count($recipients)) {
    return false;
  }
 
  $message->setTo($recipients);
 
  // subject
  $message->setSubject($subject);
 
  // html
  $message->setBody($html, 'text/html', 'utf-8');
 
  // plain
  if ($plain) {
    $message->addPart($plain, 'text/plain', 'utf-8');
  }
 
  // returnPath
  if (trim($returnPath)) {
    $message->setReturnPath($returnPath);
  }
 
  // replyTo
  if (trim($replyToEmail) && \TYPO3\CMS\Core\Utility\GeneralUtility::validEmail($replyToEmail)) {
    if (trim($replyToName)) {
      $message->setReplyTo(array($replyToEmail => $replyToName));
    } else {
      $message->setReplyTo(array($replyToEmail));
    }
  }
 
  // attachements
  if (count($attachements)) {
    foreach ($attachements as $file => $name) {
      if (file_exists($file)) {
        if (trim($name)) {
          $message->attach(Swift_Attachment::fromPath($file)->setFilename($name));
        } else {
          $message->attach(Swift_Attachment::fromPath($file));
        }
      }
    }
  }
 
  // send
  $message->send();
 

}
so funktioniert es.
hat jeman eine Idee warum?




More information about the TYPO3-german mailing list