У меня возникла эта проблема, так как я начал использовать 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
Вот как Я получаю в Outlook
This is I received after change
Не могли бы вы попытаться удалить '-> addPart ($ addpart, 'text/html')' и отправить его в gmail. Каков ваш исход? –
Ahhhaaa ... Это сработало. но дал мне это в результате. ** Привет, У вас есть приглашение принять участие в вашей работе в проекте Тестирование с критикой
Примите приглашение и начните участвовать в нем.
Accept Invitation ** @JamieSterling – Dhavs
Попробуйте изменить '-> setBody ($ body, 'text/html')' и в вашем '$ body' вставьте в него содержимое' $ addpart', не используйте '-> addpart '. Иль не дал ему ответа. –