如何使用codeigniter将电子邮件直接发送到gmail收件箱而不是垃圾邮件

时间:2017-12-07 15:12:31

标签: php codeigniter

我想使用codeigniter向gmail收件箱发送电子邮件而不是span。我写了以下代码,但发送到垃圾邮件而不是收件箱的电子邮件。

我的代码:

<?php
$this->load->library('email');

                        //SMTP & mail configuration
                $email = $this->input->post('email');
                        $config = array(
                            'protocol'  => 'tls',
                           // 'protocol'  => 'smtp',
                            'smtp_host' => 'ssl://smtp.googlemail.com',
                            'smtp_port' => 465,
                            'smtp_user' => 'mitesh.ebiztrait@gmail.com',
                            'smtp_pass' => '*****',
                            'mailtype'  => 'html',
                            'charset'   => 'utf-8',
                            'mailpath' => '/usr/sbin/sendmail',
                             'wordwrap' => TRUE,
                        );
                        $this->email->initialize($config);
                        $this->email->set_mailtype("html");
                        $this->email->set_newline("\r\n");


                        //Email content
                $data = 'http://52.14.24.245/upload/images/purchasedticket/'.$qrcode_image;

                $htmlContent .=  '<!DOCTYPE html>
                <html>
                <head>
                    <meta charset="utf-8">
                    <meta http-equiv="X-UA-Compatible" content="IE=edge">
                    <title> </title>
                    <link rel="stylesheet" href="">
                </head>
                <body> 
                    <p>Hi ,</p><br>
                    <strong>Payment for party ticket is successfull! </strong>

                    <p>Following is the QR Code, kindly present this QR code while you attend the party. </p>
                    <br>
                    URL : '.$data.'
                    <br>
                    <img src="'.$data.'"  / ><br />
                    <br>

                    Thanksbr, <br><br>
                    TheMove Team
                </body>
                </html>';
                        // $htmlContent = 'TheMove: party ticket purchase success!!';
                        // $htmlContent .= '<p>This email has sent via SMTP server from CodeIgniter application.</p>';

                        $this->email->to($email);
                        $this->email->from('ashvin.ebiztrait@gmail.com','Party App');
                        $this->email->subject('TheMove: party ticket purchase success!!');
                        $this->email->message($htmlContent);

                        //Send email
                        $data = $this->email->send();   
?>

如何直接向gmail收件箱发送电子邮件而非垃圾邮件?

2 个答案:

答案 0 :(得分:1)

确保电子邮件内容少于&#34;垃圾邮件,如&#34;。减少HTML和图像,确保您有足够的副本并通过一些在线验证器运行它。

看起来你在主题中使用了很多惊叹号,来自字段是典型的垃圾邮件等等。这不是CI的问题,而是电子邮件副本

答案 1 :(得分:0)

检查所有要通过电子邮件发送的变量和数据。