php - Email body is blank when receiving it in GMAIL - Swiftmailer -
i have been having issue, since started using swiftmailer. know new @ might doing wrong. appreciated.
issue is: receive blank body in gmail receive expected in outlook/yahoo.
i not sure issue is. in advance answering.
here call function send email attributes
$subject = "croct admin - evaluate performance of participant project - '".$result2['project_name']."'"; $from = array('test@test.com' => 'tasty'); $to = $result4[$i]['email']; $body = 'hello, have got invitiation participate work in project '.$result2['project_name'].' accept invitation , 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)**;
here function send_mail
function send_email($subject, $from, $to, $body, $addpart) { require_once apppath.'libraries/swift_mailer/swift_required.php'; //create transport $transport = swift_mailtransport::newinstance(); /* alternatively use different transport such sendmail or mail: //sendmail $transport = swift_sendmailtransport::newinstance('/usr/sbin/sendmail -bs'); //mail $transport = swift_mailtransport::newinstance(); */ //create message $message = swift_message::newinstance(); //give message subject $message->setsubject($subject) ->setfrom($from) ->setto($to) ->setbody($body, 'text/plain') ->addpart($addpart, 'text/html') ; //create mailer using created transport $mailer = swift_mailer::newinstance($transport); //send message $result = $mailer->send($message); if ($result) { $this->session->set_flashdata('error', 'invitation sent.'); } else { $this->session->set_flashdata('error', 'error occured.'); } }
that's how receive in gmail
that's how receive in outlook
as comments, should accepted major email providers.
tested:
- gmail
- outlook
- yahoo
- kerio
mailfunction:
function send_email($subject, $from, $to, $body, $addpart) { require_once apppath.'libraries/swift_mailer/swift_required.php'; //create transport $transport = swift_mailtransport::newinstance(); /* alternatively use different transport such sendmail or mail: //sendmail $transport = swift_sendmailtransport::newinstance('/usr/sbin/sendmail -bs'); //mail $transport = swift_mailtransport::newinstance(); */ //create message $message = swift_message::newinstance(); //give message subject $message->setsubject($subject) ->setfrom($from) ->setto($to) ->setbody($body, 'text/html') ; //create mailer using created transport $mailer = swift_mailer::newinstance($transport); //send message $result = $mailer->send($message); if ($result) { $this->session->set_flashdata('error', 'invitation sent.'); } else { $this->session->set_flashdata('error', 'error occured.'); } }
attributes:
$subject = "croct admin - evaluate performance of participant project - '".$result2['project_name']."'"; $from = array('test@test.com' => 'tasty'); $to = $result4[$i]['email']; $body = 'hello, have got invitiation participate work in project '.$result2['project_name'].' accept invitation , 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)**;
Comments
Post a Comment