ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Gmail + SMTP + Linux + Email library

March 28, 2010 5:49pm

Subscribe [7]
  • #1 / Mar 28, 2010 5:49pm

    chik3n

    8 posts

    Hi,

    I have readed many posts about this problem but still I have some problems my initial config looks like this :

          $configmail = array(
            ‘protocol’ => ‘smtp’,
            ‘smtp_host’ => ‘ssl://smtp.gmail.com’,
            ‘smtp_user’ => ‘my.login.name’,
            ‘smtp_pass’ => ‘password’,
            ‘smtp_port’ => 465,
            ‘wordwrap’ => TRUE,
            ‘mailtype’ => ‘text’,
            ‘charset’ => ‘utf-8’
            );
          $this->load->library(‘email’, $configmail);

    and the part of code that sends the mail :

            $this->email->from(‘[email protected]’, ‘name’);
            $this->email->to($reg_email);
            $this->email->subject(‘topic’);
            $this->email->message(‘testowa’);
            $this->email->send();
                    echo $this->email->print_debugger();

    and still I get this kind of output :

    220 mx.google.com ESMTP s10sm13968098mue.27
    hello: 250-mx.google.com at your service, [xxx.xx.xx.xx]
    250-SIZE 35651584
    250-8BITMIME
    250-AUTH LOGIN PLAIN XOAUTH
    250-ENHANCEDSTATUSCODES
    250 PIPELINING
    from: 250 2.1.0 OK s10sm13968098mue.27
    to: 250 2.1.5 OK s10sm13968098mue.27
    data: 354 Go ahead s10sm13968098mue.27
    451 4.4.2 Timeout - closing connection. s10sm13968098mue.27
    The following SMTP error was encountered: 451 4.4.2 Timeout - closing connection. s10sm13968098mue.27
    Unable to send email using PHP SMTP. Your server might not be configured to send mail using this method.
    User-Agent: CodeIgniter
    Date: Sun, 28 Mar 2010 22:39:28 -0400
    From: “name”
    Return-Path:
    To: .(JavaScript must be enabled to view this email address)
    Subject: =?utf-8?Q?topic?=
    Reply-To: “[email protected]
    X-Sender: .(JavaScript must be enabled to view this email address)
    X-Mailer: CodeIgniter
    X-Priority: 3 (Normal)
    Message-ID: <[email protected]>
    Mime-Version: 1.0


    Content-Type: text/plain; charset=utf-8
    Content-Transfer-Encoding: 8bit

    testowa

    I have this on Linux Debian server if u want some kind of output just say. Can any one help me with this problem ?

  • #2 / Mar 28, 2010 6:19pm

    2think

    125 posts

    Hi chik3n,

    Few things to check since I had problems initially on Fedora:

    1. Make sure your iptables (firewall) allows outbound and inbound on that port. Looking over your error return message I think you may be ok with that.

    2. In your username in your config, make sure you put .(JavaScript must be enabled to view this email address). That is, include the @gmail.com part.

  • #3 / Mar 28, 2010 6:24pm

    chik3n

    8 posts

    Here is the thing, I’m using other php script from php classes to send email via php and gmail and it works just fine so something must be wrong in codeigniter, as for the firewall is all ok because that other script is working on the same port :/. Any other ideas ? Oh right I putted the ‘@gmail.com’ on the end of the login and same story, nothing, is that posible that the problem is I got dots in login name ?

    Edit:

    I’d try another email where login dont have dots, same thing :/.

  • #4 / Mar 28, 2010 7:22pm

    2think

    125 posts

    Wish I knew more about SMTP but give this a try:

    ‘smtp_host’ => ‘ssl://smtp.googlemail.com’,

  • #5 / Mar 28, 2010 7:25pm

    chik3n

    8 posts

    Nope :/ same thing I’m confused :/.

  • #6 / Mar 29, 2010 3:40am

    eoinmcg

    311 posts

    have you tried logging in to this gmail account via your browser?

    some times when sending lots of test mails gmail thinks you’re spamming and suspends the account.

  • #7 / Mar 29, 2010 4:19am

    chik3n

    8 posts

    Yes I can log in via the browser on the account so that is not the problem and I was trying to send only 3-7 email in period of 10-30 minutes so I think that spam we can canceled as well.

  • #8 / Mar 29, 2010 8:32am

    eoinmcg

    311 posts

    just tried your code (with my gmail account) and also got a timeout error. compared it with some working code and it seems gmail doesn’t like either all or a combination of setting wordwrap, mailtype, charset and not setting new line char…

    $configmail = array(
                'protocol' => 'smtp',
                'smtp_user' => 'my.login.name',
                'smtp_pass' => 'password',
                'smtp_port' => 465
                );
              $this->load->library('email', $configmail); 
    
                $this->email->set_newline("\r\n");
    
                $this->email->from(‘[email protected]’, ‘name’);
                $this->email->to($reg_email);
                $this->email->subject('topic');
                $this->email->message('testowa');
                $this->email->send();
    
                echo $this->email->print_debugger();

    Obviously you could be a bit more scientific and investigate which of these is causing the problem and why 😛

  • #9 / Mar 29, 2010 2:59pm

    chik3n

    8 posts

    Still nothing, I try everything, even creating an new controler only to send one email and still nothing :/.

    Any other ideas ?

  • #10 / Mar 29, 2010 8:30pm

    theshiftexchange

    211 posts

    this is my email config for gmail which works:

    $config['protocol']     = 'smtp';
    $config['smtp_host']    = 'ssl://smtp.googlemail.com';
    $config['smtp_port']    = 465;
    $config['smtp_user']    = '[email protected]';
    $config['smtp_pass']    = 'MYPASSWORD';
    $config['smtp_timeout'] = 30;
    $config['newline']      = "\r\n";
    $config['crlf']         = "\r\n";
    $config['mailtype']     = 'html';
    $config['charset']      = 'utf-8';

    I cant remember - do you need to enable smtp in your gmail account or something mayube?

  • #11 / Apr 01, 2010 9:49am

    Imran Tariq

    9 posts

    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

    <?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

    
    
    

    The Error I am getting after uploading

    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: .(JavaScript must be enabled to view this email address) Subject: =?iso-8859-1?Q?Email_Subject?= =?iso-8859-1?Q?0?= Reply-To: “[email protected]” X-Sender: .(JavaScript must be enabled to view this email address) 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: .(JavaScript must be enabled to view this email address)
    Subject: =?iso-8859-1?Q?Email_Subject?=
    =?iso-8859-1?Q?0?=
    Reply-To: “[email protected]
    X-Sender: .(JavaScript must be enabled to view this email address)
    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”><html><head><title></title></head><body><table bor=
    der=3D"0” cellpadding=3D"5” cellspacing=3D"0”><tr>
                  <td nowrap=3D"nowrap” align=3D"right” >Name=
    :</td><td>Test Last, Test First</td>
                  </tr></table></body></html>

    —B_ALT_4bb49470ec029—

    Please ANYONE CAN HELP ME to resolve the issue.

  • #12 / Apr 01, 2010 10:05am

    rogierb

    697 posts

    Maybe a stupid question, but is port 25 blocked?
    Have you tried an alternative port?

  • #13 / Apr 01, 2010 10:10am

    Imran Tariq

    9 posts

    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 / Apr 25, 2010 8:18pm

    shane_

    11 posts

    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:

    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

    suhosin.mail.protect = 1

    to

    suhosin.mail.protect = 0

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

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases