Gmail + SMTP + Linux + Email library

#11
[eluser]Imran Tariq[/eluser]
I have the same issue in my Application while using Email Library. I have the script the following script which is working fine on my local server (Win OS), but when I upload it, the script gave me the error. See below.

The Controller Code

Code:
<?php
class Email extends Controller
{
    function Email()
    {
        parent::Controller();
        $this->load->library('email');
    }

    function index()
    {
        $this->load->model('EmailTesting');
        $this->EmailTesting->emailTest();
    }
}?>

The (EmailTesting) Model Code
Code:
<?php
class EmailTesting extends Model
{
    function EmailTesting()
    {
        parent::Model();
        $this->load->helper('email');
        error_reporting(0);
    }
    
    function emailTest()
    {
        $config    = array('protocol'    => 'smtp',
                        'smtp_host'    => 'smtpout.secureserver.net',
                        'smtp_port'    => 25,
                        'smtp_user' => '[email protected]',
                        'smtp_pass'    => 'password',
                        'mailtype'    => 'html',
                        'charset'    => 'iso-8859-1'
                        );
        $this->load->library('email', $config);

        $this->email->initialize($config);

        $Email        = '[email protected]';
        $Subject    = 'Email Subject';
        $Message    = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">&lt;html&gt;&lt;head>&lt;title&gt;&lt;/title>&lt;/head&gt;&lt;body><table border="0" cellpadding="5" cellspacing="0"><tr>
                       <td nowrap="nowrap" align="right" style="font-weight:bold">Name :</td><td>Test Last, Test First</td>
                       </tr></table>&lt;/body&gt;&lt;/html>';
        $this->email->set_newline("\r\n");
        $this->email->from('[email protected]', 'Testing Email');
        $this->email->to($Email);
        $this->email->subject($Subject);

        $this->email->message($Message);
        
        $result        = $this->email->send();
        echo $this->email->print_debugger();
        return $result;
    }
}?&gt;

The Error I am getting after uploading

Quote:The following SMTP error was encountered: 110 Connection timed out
Unable to send data: AUTH LOGIN
Failed to send AUTH LOGIN command. Error:
Unable to send data: MAIL FROM:

from:

The following SMTP error was encountered:
Unable to send data: RCPT TO:

to:

The following SMTP error was encountered:
Unable to send data: DATA

data:

The following SMTP error was encountered:
Unable to send data: User-Agent: CodeIgniter Date: Thu, 1 Apr 2010 05:41:20 -0700 From: "Testing Email" Return-Path: To: [email protected] Subject: =?iso-8859-1?Q?Email_Subject?= =?iso-8859-1?Q?0?= Reply-To: "[email protected]" X-Sender: [email protected] X-Mailer: CodeIgniter X-Priority: 3 (Normal) Message-ID: <[email protected]> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="B_ALT_4bb49470ec029" This is a multi-part message in MIME format. Your email application may not support this format. --B_ALT_4bb49470ec029 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Name :Test Last, Test First --B_ALT_4bb49470ec029 Content-Type: text/html; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable
Name= : Test Last, Test First
--B_ALT_4bb49470ec029--
Unable to send data: .

The following SMTP error was encountered:
Unable to send email using PHP SMTP. Your server might not be configured to send mail using this method.

User-Agent: CodeIgniter
Date: Thu, 1 Apr 2010 05:41:20 -0700
From: "Testing Email"
Return-Path:
To: [email protected]
Subject: =?iso-8859-1?Q?Email_Subject?=
=?iso-8859-1?Q?0?=
Reply-To: "[email protected]"
X-Sender: [email protected]
X-Mailer: CodeIgniter
X-Priority: 3 (Normal)
Message-ID: <[email protected]>
Mime-Version: 1.0


Content-Type: multipart/alternative; boundary="B_ALT_4bb49470ec029"

This is a multi-part message in MIME format.
Your email application may not support this format.

--B_ALT_4bb49470ec029
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit

Name :Test Last, Test First


--B_ALT_4bb49470ec029
Content-Type: text/html; charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org=
/TR/xhtml1/DTD/xhtml1-strict.dtd">&lt;html&gt;&lt;head>&lt;title&gt;&lt;/title>&lt;/head&gt;&lt;body><table bor=
der=3D"0" cellpadding=3D"5" cellspacing=3D"0"><tr>
<td nowrap=3D"nowrap" align=3D"right" style=3D"font-weight:bold">Name=
:</td><td>Test Last, Test First</td>
</tr></table>&lt;/body&gt;&lt;/html>

--B_ALT_4bb49470ec029--

Please ANYONE CAN HELP ME to resolve the issue.

#12
[eluser]rogierb[/eluser]
Maybe a stupid question, but is port 25 blocked?
Have you tried an alternative port?

#13
[eluser]Imran Tariq[/eluser]
But if it is the problem with the PORT then why it sends a simple text email in which I have not included any html tag?

#14
[eluser]shane_[/eluser]
If you are using PHP with the Suhosin patch HTML email will be dropped at your server. If you check your server logs you'll see a message like:

Quote:ALERT - mail() - double newline in headers, possible injection, mail dropped (attacker 'xxx.xxx.xxx', file '/path/to/codeigniter/system/libraries/Email.php', line 1519)

The simple way to resolve this is to edit your php.ini. Change

Code:
suhosin.mail.protect = 1

to

Code:
suhosin.mail.protect = 0

This is why email seems to work perfectly with mailtype = text and not with mailtype = html.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.