从谷歌应用程序帐户发送PHP的电子邮件

时间:2021-08-15 18:15:22

I was sending emails with PHP but we have just migrated all to google apps.

我用PHP发送电子邮件,但我们刚刚将所有内容迁移到谷歌应用程序。

I have created a new user (support@xxxxxxxxxx.com) and I don't known what I have to do to send emails with it.

我创建了一个新用户(support@xxxxxxxxxx.com),我不知道我要用它来发送电子邮件。

I am using Codeigniter with this code:

我使用Codeigniter使用此代码:

$config = Array(
    'protocol' => 'smtp',
    'smtp_host' => 'ssl://smtp.gmail.com', //'ssl://smtp.googlemail.com'
    'smtp_port' => '587',
    'smtp_timeout' => '30',
    'smtp_user' => 'support@xxxxxxxxxx.com',
    'smtp_pass' => 'passExample',
    'mailtype' => 'html',
    'charset' => 'utf-8',
    'newline' => '\r\n',
    'wordwrap' => TRUE
);
$this->load->library('email', $config);

$this->email->from("support@xxxxxxxxxx.com", "Support");
$this->email->to($to);
$this->email->subject($subject);

$this->email->message($message);
if($this->email->send())
{
    return true;
}
else
{
    $error=$CI->email->print_debugger();
    return $error;
}

Any help??

任何帮助?


I try to follow this link: https://support.google.com/a/answer/176600?hl=es and this https://support.google.com/a/answer/2956491

我尝试关注此链接:https://support.google.com/a/answer/176600?hl = es和https://support.google.com/a/answer/2956491

And this is what I have on gmail admin panel of google apps: 从谷歌应用程序帐户发送PHP的电子邮件

这就是我在google apps的gmail管理面板上所拥有的:

The password is correct because I can log in into Gmail and these are the errors:

密码正确,因为我可以登录Gmail,这些是错误:

with port: 25 and host:aspmx.l.google.com

使用端口:25和主机:aspmx.l.google.com

sendEmail=220 mx.google.com ESMTP 142si1984800wmg.122 - gsmtp 
hello: 250-mx.google.com at your service, [2a02:be8:1:700:4525:cbbd:7e41:9fed]
250-SIZE 35882577
250-8BITMIME
250-STARTTLS
250-ENHANCEDSTATUSCODES
250-PIPELINING
250-CHUNKING
250 SMTPUTF8
error sending AUTH LOGIN command. Error: 503 5.5.1 bad sequence of commands 142si1984800wmg.122 - gsmtp 
from: 250 2.1.0 OK 142si1984800wmg.122 - gsmtp
to: 250 2.1.5 OK 142si1984800wmg.122 - gsmtp
data: 354  Go ahead 142si1984800wmg.122 - gsmtp

SSL with port: 465 and host:smtp.gmail.com

带端口的SSL:465和host:smtp.gmail.com

TLS with port: 587 and host:smtp.gmail.com

TLS端口:587,主机:smtp.gmail.com

hello: F
SMTP The following errors have been found:
error sending AUTH LOGIN command. Error: 
from: 
SMTP The following errors have been found:
to: 
SMTP The following errors have been found:
data: 
SMTP The following errors have been found:
You can not send mail using SMTP PHP. Your server may be configured to use this method of shipment.

2 个解决方案

#1


1  

I solve it!

我解决了!

The problem is that with Codeignter 2.X it doesn't work. I download codeigniter 3 and it works for me with this configuration:

问题是使用Codeignter 2.X它不起作用。我下载了codeigniter 3,它适用于我这个配置:

$config = Array(
        'useragent' => 'ermes',
        'protocol' => 'mail',
        'smtp_host' => 'smtp.gmail.com',
        'smtp_port' => '465',
        'smtp_user' => 'support@xxxxxxxxxxxx.com',
        'smtp_pass' => 'xxxxxxxxxxxx',
        'smtp_crypto' => 'ssl',
        'mailtype' => 'html',
        'charset' => 'utf-8',
        'newline' => '\r\n',
        'wordwrap' => TRUE
    );

I need to change the protocol from smtp to mail and add smtp_crypto (this function is not in Codeigniter 2.X)

我需要将协议从smtp更改为mail并添加smtp_crypto(此函数不在Codeigniter 2.X中)

Also I did not make changes in my gmail configration (in google apps).

此外,我没有在我的Gmail电子邮件配置中进行更改(在谷歌应用程序中)。

#2


0  

Sending email using google app requires few steps to complete before google actually start sending the emails you ask for...

使用谷歌应用程序发送电子邮件需要几个步骤才能完成谷歌实际开始发送您要求的电子邮件...

what's the problem:

有什么问题:

You need to activate sending emails from unsecured sources from google.

您需要激活从谷歌发送来自不安全来源的电子邮件。

How to do it:

怎么做:

gmail will send you an email to support@xxxxxxxxxx.com when first time you execute the code, where your required to click on activate button. After that all the emails google will forward

当您第一次执行代码时,gmail会向您发送电子邮件至support@xxxxxxxxxx.com,您需要点击激活按钮。之后谷歌的所有电子邮件都将转发

Why this happens

为什么会这样

Sending email directly using php is generally considered as spam. so security check for 1 time is required.

使用php直接发送电子邮件通常被视为垃圾邮件。因此需要进行一次安全检查。

Hope you get your code started working, you also need to check that your hosting has unlimited email forwarding facility.

希望您的代码开始工作,您还需要检查您的主机是否具有无限的电子邮件转发功能。

best luck...

好运...

#1


1  

I solve it!

我解决了!

The problem is that with Codeignter 2.X it doesn't work. I download codeigniter 3 and it works for me with this configuration:

问题是使用Codeignter 2.X它不起作用。我下载了codeigniter 3,它适用于我这个配置:

$config = Array(
        'useragent' => 'ermes',
        'protocol' => 'mail',
        'smtp_host' => 'smtp.gmail.com',
        'smtp_port' => '465',
        'smtp_user' => 'support@xxxxxxxxxxxx.com',
        'smtp_pass' => 'xxxxxxxxxxxx',
        'smtp_crypto' => 'ssl',
        'mailtype' => 'html',
        'charset' => 'utf-8',
        'newline' => '\r\n',
        'wordwrap' => TRUE
    );

I need to change the protocol from smtp to mail and add smtp_crypto (this function is not in Codeigniter 2.X)

我需要将协议从smtp更改为mail并添加smtp_crypto(此函数不在Codeigniter 2.X中)

Also I did not make changes in my gmail configration (in google apps).

此外,我没有在我的Gmail电子邮件配置中进行更改(在谷歌应用程序中)。

#2


0  

Sending email using google app requires few steps to complete before google actually start sending the emails you ask for...

使用谷歌应用程序发送电子邮件需要几个步骤才能完成谷歌实际开始发送您要求的电子邮件...

what's the problem:

有什么问题:

You need to activate sending emails from unsecured sources from google.

您需要激活从谷歌发送来自不安全来源的电子邮件。

How to do it:

怎么做:

gmail will send you an email to support@xxxxxxxxxx.com when first time you execute the code, where your required to click on activate button. After that all the emails google will forward

当您第一次执行代码时,gmail会向您发送电子邮件至support@xxxxxxxxxx.com,您需要点击激活按钮。之后谷歌的所有电子邮件都将转发

Why this happens

为什么会这样

Sending email directly using php is generally considered as spam. so security check for 1 time is required.

使用php直接发送电子邮件通常被视为垃圾邮件。因此需要进行一次安全检查。

Hope you get your code started working, you also need to check that your hosting has unlimited email forwarding facility.

希望您的代码开始工作,您还需要检查您的主机是否具有无限的电子邮件转发功能。

best luck...

好运...