2015-07-02 2 views
0

Теперь я создаю одно довольно крупное веб-приложение корпоративного уровня на нашем производственном сервере.отправка электронной почты в Laravel 5 с учетной записью Google Apps не работает

пока я развивался на локальном сервере разработки, отправка почты не вызывала большого беспокойства, но на живом этапе это стало большой болью в моем прикладе.

Я искал больше, чем 3 дня, и попытался использовать параметры драйвера mandrill, postfix и sendmail в Laravel, но я не мог этого добиться.

, так что любой, кто испытал разработку отправки писем на Laravel с учетной записью Google Apps ???

APP_DEBUG=true 
APP_KEY=my app key 

MAIL_DRIVER=smtp 
MAIL_HOST=smtp.mandrillapp.com 
[email protected] 
MAIL_PASSWORD=my api key 

выше мой .env файл веб-приложения

и лог показанный ниже журнал, когда почта не удается отправить

[2015-07-02 17:56:16] production.ERROR: exception 'Swift_TransportException' with message 'Expected response code 250 but got code "535", with message "535-5.7.8 Username and Password not accepted. Learn more at^M 535 5.7.8 https://support.google.com/mail/answer/14257 gs7sm4872423pbc.6 - gsmtp^M "' in /home/thecorp-admin/Services/TheMandarin/Trinity/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php:383 Stack trace:

просто упаковывают я обеспечит некоторую полезную информацию.

вышеуказанному ссылка не работает с Аккаунты Google Apps

+0

Привет, Я использую Laravel для отправки электронной почты с использованием учетных записей бизнес-gmail и не имел слишком много проблем. Использует ли учетная запись, которую вы пытаетесь использовать, имеет двухэтапную аутентификацию? –

ответ

0

Это ответ, используя gmails SMTP-сервер

В вашем App \ Config \ mail.php

/* 
    |-------------------------------------------------------------------------- 
    | Mail Driver 
    |-------------------------------------------------------------------------- 
    | 
    | Laravel supports both SMTP and PHP's "mail" function as drivers for the 
    | sending of e-mail. You may specify which one you're using throughout 
    | your application here. By default, Laravel is setup for SMTP mail. 
    | 
    | Supported: "smtp", "mail", "sendmail", "mailgun", "mandrill", "log" 
    | 
    */ 

    'driver' => 'smtp', 

    /* 
    |-------------------------------------------------------------------------- 
    | SMTP Host Address 
    |-------------------------------------------------------------------------- 
    | 
    | Here you may provide the host address of the SMTP server used by your 
    | applications. A default option is provided that is compatible with 
    | the Mailgun mail service which will provide reliable deliveries. 
    | 
    */ 

    'host' => 'smtp.gmail.com', 

    /* 
    |-------------------------------------------------------------------------- 
    | SMTP Host Port 
    |-------------------------------------------------------------------------- 
    | 
    | This is the SMTP port used by your application to deliver e-mails to 
    | users of the application. Like the host we have set this value to 
    | stay compatible with the Mailgun e-mail application by default. 
    | 
    */ 

    'port' => 587, 

    /* 
    |-------------------------------------------------------------------------- 
    | Global "From" Address 
    |-------------------------------------------------------------------------- 
    | 
    | You may wish for all e-mails sent by your application to be sent from 
    | the same address. Here, you may specify a name and address that is 
    | used globally for all e-mails that are sent by your application. 
    | 
    */ 

    'from' => ['address' => '[email protected]', 'name' => 'Ted notification'], 

    /* 
    |-------------------------------------------------------------------------- 
    | E-Mail Encryption Protocol 
    |-------------------------------------------------------------------------- 
    | 
    | Here you may specify the encryption protocol that should be used when 
    | the application send e-mail messages. A sensible default using the 
    | transport layer security protocol should provide great security. 
    | 
    */ 

    'encryption' => 'tls', 

    /* 
    |-------------------------------------------------------------------------- 
    | SMTP Server Username 
    |-------------------------------------------------------------------------- 
    | 
    | If your SMTP server requires a username for authentication, you should 
    | set it here. This will get used to authenticate with your server on 
    | connection. You may also set the "password" value below this one. 
    | 
    */ 

    'username' => '[email protected]', 

    /* 
    |-------------------------------------------------------------------------- 
    | SMTP Server Password 
    |-------------------------------------------------------------------------- 
    | 
    | Here you may set the password required by your SMTP server to send out 
    | messages from your application. This will be given to the server on 
    | connection so that the application will be able to send messages. 
    | 
    */ 

    'password' => 'myPassword', 

Если вы используете двухэтапная проверка вам нужно получить пароль приложения. Для этого перейдите в свою учетную запись google, войдите в настройки и добавьте новое приложение. Вам нужно будет выбрать другое. Google предоставит вам пароль, который вам нужно будет использовать в этом конфигурационном файле

+0

вот что я точно сделал. – user2809760

+0

Какие ошибки вы получили –

+0

У меня возникла ошибка: Ожидаемый код ответа 250, но получил код «530», с сообщением «530-5.5.1 Требуется аутентификация. Подробнее ... 530 5.5.1 https: // support .google.com/mail /? p = WantAuthError e190sm2996547pfa.41 - gsmtp " –

Смежные вопросы