Welcome Guest, Not a member yet? Register   Sign In
can't send smtp email with google apps email
#1

[eluser]chrisco23[/eluser]
Hi all,

I'm having trouble getting any email to go out when trying to use one of my google apps email accounts.

I have these accounts working in Thunderbird just fine, and I use imap.gmail.com, port 993, SSL for inbound email, and smtp.gmail.com, port 587, TLS, outbound.

I only need outbound mail from my Code Igniter website though.

Can anyone help?

My /application/config/email.php settings are:

Code:
$config['protocol'] = 'smtp';
$config['smtp_host'] = 'smtp.gmail.com';
$config['smtp_port'] = '587';
$config['smtp_user'] = '[email protected]';
$config['smtp_pass'] = 'mypassword';
$config['newline'] = "\r\n";


Thanks!
Chris
#2

[eluser]wiredesignz[/eluser]
I may be mistaken, but smtp relay might not be allowed through gmail. On the other hand it may require your proper gmail account details for smtp_user.
#3

[eluser]chrisco23[/eluser]
I've got the fire mostly put out by using PHPMailer class.

Still, would like to know if this could be accomplished in a more native CI fashion.

thx.
#4

[eluser]bd3521[/eluser]
Any luck with sending via gmail or google apps with CI?
#5

[eluser]chrisco23[/eluser]
Like I said in my post from a year ago, I had success with PHPMailer

http://sourceforge.net/projects/phpmailer/

I use the PHPMailer class and the SMTP class.

Here's a send method I have. Just modify this to suit your needs. Obviously make sure $_POST is clean etc.


Code:
public function send() {
        $this->load->library('SMTP');
        $this->load->library('PHPMailer');

        $mail = new PHPMailer();
        $mail->IsSMTP();
        $mail->SMTPAuth = TRUE;
        $mail->Username ='my_email_address@my_domain.com';
        $mail->Password ='my_email_password';
        $mail->From = $_POST['from'];
        $mail->FromName = $_POST['from'];

        if ($_POST['to'] == 'sales') {
            $mail->AddAddress('sales@my_domain.com', 'sales@my_domain.com');
        }
        elseif ($_POST['to'] == 'support') {
            $mail->AddAddress('support@my_domain.com', 'support@my_domain.com');
        }
        $mail->AddReplyTo($mail->FromName, $mail->FromName);

        $mail->Subject = $_POST['subject'];
        $mail->Body = $_POST['contactBody'];
        $mail->IsHTML(true);

        if(!$mail->Send()) {
            return $mail->ErrorInfo;
        }
        else {
            return TRUE;
        }
    }
#6

[eluser]Crimp[/eluser]
I managed to get away from the PHPMailer plug-in by using this config with the CI class:

Code:
'protocol'    => 'smtp',
'smtp_host'    => 'ssl://smtp.googlemail.com',
'smtp_port'    => 465,
'smtp_user'    => 'your_gmail_email_account',
'smtp_pass'    => 'your_gmail_password',
'charset'    => 'utf-8',
'newline'    => "\r\n"
#7

[eluser]randomdriver[/eluser]
Call me stupid, when I read this:

http://ellislab.com/codeigniter/user-gui...email.html

It mentions add the $config array in that file... OK. So and array that looks like?

$config['value'] = 'some value';

Or $config = array('value1, value2);

I tried the first and get an ugly error about headers being sent out etc. I too am trying to get my app to send emails via a Google Account.
#8

[eluser]Unknown[/eluser]
Hi,

I realise this is an old thread but the issue still seems to exist.

After playing around I found that if i did not have the following line the send would just hang:

'newline' => "\r\n"

If I add it in the send works fine.

My full config:

$config = Array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.googlemail.com',
'smtp_port' => 465,
'smtp_user' => 'support@*****',
'smtp_pass' => '*****',
'charset' => 'iso-8859-1',
'newline' => "\r\n"
);
$this->load->library('email', $config);

I tested several times and the 'newline' was the difference between it working or not.
#9

[eluser]Unknown[/eluser]
earned!!!

ysadba.org[/size][/size]




Theme © iAndrew 2016 - Forum software by © MyBB