2015-06-10 1 views
1

У меня возникла эта проблема, так как я начал использовать Swiftmailer. Я знаю, что я новичок в этом, поэтому может быть что-то неправильно. Любая помощь будет оценена по достоинству.Тело электронной почты пуста при получении его в GMAIL - Swiftmailer

Издание является: я получаю пустой корпус только в GMAIL, но получить все, как ожидается, в OUTLOOK/YAHOO.

Я не уверен, в чем проблема. Заранее спасибо за ответ.

Здесь я вызываю функцию, чтобы отправить по электронной почте со всеми атрибутами

$subject = "CROCT Admin - Evaluate performance of participant for project - '".$result2['project_name']."'"; 
    $from = array('[email protected]' => 'Tasty'); 
    $to = $result4[$i]['email']; 
    $body = 'Hello, You have got an invitiation to participate your work in project '.$result2['project_name'].' Accept the invitation and start participating in it.' .anchor('https://example.org/'.$project_id_url.'/'.$result4[$i]['user_id'], 'Accept Invitation'); 
    $addpart = 'Best,Team CROCT'; 
    $this->**send_email($subject, $from, $to, $body, $addpart)**; 

Вот функция send_mail

function send_email($subject, $from, $to, $body, $addpart) 
     { 
      require_once APPPATH.'libraries/swift_mailer/swift_required.php'; 
      //Create the Transport 
      $transport = Swift_MailTransport::newInstance(); 
      /* 
      You could alternatively use a different transport such as Sendmail or Mail: 
      //Sendmail 
      $transport = Swift_SendmailTransport::newInstance('/usr/sbin/sendmail -bs'); 
      //Mail 
      $transport = Swift_MailTransport::newInstance(); 
      */ 
      //Create the message 
      $message = Swift_Message::newInstance(); 
      //Give the message a subject 
      $message->setSubject($subject) 
        ->setFrom($from) 
        ->setTo($to) 
        ->setBody($body, 'text/plain') 
        ->addPart($addpart, 'text/html') 
      ; 
      //Create the Mailer using your created Transport 
      $mailer = Swift_Mailer::newInstance($transport); 
      //Send the message 
      $result = $mailer->send($message); 
      if ($result) { 
       $this->session->set_flashdata('error', 'Invitation sent.'); 
      } else { 
       $this->session->set_flashdata('error', 'Error occured.'); 
      } 
     } 

Вот как я получаю в Gmail Result I am getting in email - Just for GMAIL

Вот как Я получаю в Outlook This is what I receive in OUTLOOK

This is I received after change enter image description here

+1

Не могли бы вы попытаться удалить '-> addPart ($ addpart, 'text/html')' и отправить его в gmail. Каков ваш исход? –

+0

Ahhhaaa ... Это сработало. но дал мне это в результате. ** Привет, У вас есть приглашение принять участие в вашей работе в проекте Тестирование с критикой
Примите приглашение и начните участвовать в нем.
Accept Invitation ** @JamieSterling – Dhavs

+0

Попробуйте изменить '-> setBody ($ body, 'text/html')' и в вашем '$ body' вставьте в него содержимое' $ addpart', не используйте '-> addpart '. Иль не дал ему ответа. –

ответ

1

Что касается комментариев, то это должно быть принято всеми основными поставщиками электронной почты.

Испытано:

  • Gmail
  • перспективы
  • Yahoo
  • Kerio

MailFunction:

function send_email($subject, $from, $to, $body, $addpart) 
     { 
      require_once APPPATH.'libraries/swift_mailer/swift_required.php'; 
      //Create the Transport 
      $transport = Swift_MailTransport::newInstance(); 
      /* 
      You could alternatively use a different transport such as Sendmail or Mail: 
      //Sendmail 
      $transport = Swift_SendmailTransport::newInstance('/usr/sbin/sendmail -bs'); 
      //Mail 
      $transport = Swift_MailTransport::newInstance(); 
      */ 
      //Create the message 
      $message = Swift_Message::newInstance(); 
      //Give the message a subject 
      $message->setSubject($subject) 
        ->setFrom($from) 
        ->setTo($to) 
        ->setBody($body, 'text/html') 
      ; 
      //Create the Mailer using your created Transport 
      $mailer = Swift_Mailer::newInstance($transport); 
      //Send the message 
      $result = $mailer->send($message); 
      if ($result) { 
       $this->session->set_flashdata('error', 'Invitation sent.'); 
      } else { 
       $this->session->set_flashdata('error', 'Error occured.'); 
      } 
     } 

Атрибуты:

$subject = "CROCT Admin - Evaluate performance of participant for project - '".$result2['project_name']."'"; 
$from = array('[email protected]' => 'Tasty'); 
$to = $result4[$i]['email']; 
$body = 'Hello, You have got an invitiation to participate your work in project '.$result2['project_name'].' Accept the invitation and start participating in it.' .anchor('https://example.org/'.$project_id_url.'/'.$result4[$i]['user_id'], 'Accept Invitation').'<br>Best,Team CROCT'; 
$this->**send_email($subject, $from, $to, $body)**; 
+0

Это сработало. Но не уверен, что делать с текстом, указанным в электронной почте. Это похоже на перенаправленную электронную почту. Я добавил изображение, о котором идет речь. @JamieSterling – Dhavs

+0

Являются ли эти, одинарные или двойные кавычки? мог бы добавить ссылку на скриншот –

+0

Я тебя не понял. Ссылка на то, где? Я добавил скриншот на вопрос. @jamiesterling – Dhavs