Advertisement
Guest User

Issue - Gmail Laravel

a guest
Apr 9th, 2019
916
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 6.57 KB | None | 0 0
  1. //Anyone faced this issue before?
  2. //Swift_RfcComplianceException
  3. //Address in mailbox given [Sacar App] does not comply with RFC 2822, 3.6.2.
  4.  
  5. //my controller:
  6.     $name = $request->name;
  7.     $email = $request->email;
  8.     $password = $request->password;
  9.     $email = Array($request->name =>$request->email);
  10.  
  11.     $user = User::create([
  12.         'name' => $request->get('name'),
  13.         'email' => $request->get('email'),
  14.         'phone' => $request->get('phone'),
  15.         'birth_date' => $request->get('birth_date'),
  16.         'city_id' => $request->get('city_id'),
  17.         'password' => Hash::make($request->get('password')),
  18.     ]);
  19.        
  20.     $verification_code = str_random(30); //Generate verification code
  21.     DB::table('user_verifications')->insert(['user_id'=>$user->id,'token'=>$verification_code]);
  22.     $subject = "Confirme o seu E-mail";
  23.  
  24.     Mail::send('email.verify', ['name' => $name, 'verification_code' => $verification_code],
  25.             function($mail) use ($email, $name, $subject){
  26.                 $mail->from(getenv('FROM_EMAIL_ADDRESS'), "Sacar App");
  27.                 $mail->to($email, $name);
  28.                 $mail->subject($subject);
  29.             });
  30.            
  31. //my .env:
  32.     MAIL_DRIVER=smtp
  33.     MAIL_HOST=smtp.gmail.com
  34.     MAIL_PORT=587
  35.     MAIL_USERNAME=xxxxxxx@­gmail.com
  36.     MAIL_PASSWORD=xxxxx(password application)
  37.     MAIL_ENCRYPTION=tls
  38.  
  39. //my mail.php:
  40.  
  41.     <?php
  42.  
  43.     return [
  44.  
  45.         /*
  46.         |--------------------------------------------------------------------------
  47.         | Mail Driver
  48.         |--------------------------------------------------------------------------
  49.         |
  50.         | Laravel supports both SMTP and PHP's "mail" function as drivers for the
  51.         | sending of e-mail. You may specify which one you're using throughout
  52.         | your application here. By default, Laravel is setup for SMTP mail.
  53.         |
  54.         | Supported: "smtp", "sendmail", "mailgun", "mandrill", "ses",
  55.         |            "sparkpost", "postmark", "log", "array"
  56.         |
  57.         */
  58.  
  59.         'driver' => env('MAIL_DRIVER', 'smtp'),
  60.  
  61.         /*
  62.         |--------------------------------------------------------------------------
  63.         | SMTP Host Address
  64.         |--------------------------------------------------------------------------
  65.         |
  66.         | Here you may provide the host address of the SMTP server used by your
  67.         | applications. A default option is provided that is compatible with
  68.         | the Mailgun mail service which will provide reliable deliveries.
  69.         |
  70.         */
  71.  
  72.         'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
  73.  
  74.         /*
  75.         |--------------------------------------------------------------------------
  76.         | SMTP Host Port
  77.         |--------------------------------------------------------------------------
  78.         |
  79.         | This is the SMTP port used by your application to deliver e-mails to
  80.         | users of the application. Like the host we have set this value to
  81.         | stay compatible with the Mailgun e-mail application by default.
  82.         |
  83.         */
  84.  
  85.         'port' => env('MAIL_PORT', 587),
  86.  
  87.         /*
  88.         |--------------------------------------------------------------------------
  89.         | Global "From" Address
  90.         |--------------------------------------------------------------------------
  91.         |
  92.         | You may wish for all e-mails sent by your application to be sent from
  93.         | the same address. Here, you may specify a name and address that is
  94.         | used globally for all e-mails that are sent by your application.
  95.         |
  96.         */
  97.  
  98.         'from' => [
  99.             'address' => env('MAIL_FROM_ADDRESS', 'hello@example.com'),
  100.             'name' => env('MAIL_FROM_NAME', 'Example'),
  101.         ],
  102.  
  103.         /*
  104.         |--------------------------------------------------------------------------
  105.         | E-Mail Encryption Protocol
  106.         |--------------------------------------------------------------------------
  107.         |
  108.         | Here you may specify the encryption protocol that should be used when
  109.         | the application send e-mail messages. A sensible default using the
  110.         | transport layer security protocol should provide great security.
  111.         |
  112.         */
  113.  
  114.         'encryption' => env('MAIL_ENCRYPTION', 'tls'),
  115.  
  116.         /*
  117.         |--------------------------------------------------------------------------
  118.         | SMTP Server Username
  119.         |--------------------------------------------------------------------------
  120.         |
  121.         | If your SMTP server requires a username for authentication, you should
  122.         | set it here. This will get used to authenticate with your server on
  123.         | connection. You may also set the "password" value below this one.
  124.         |
  125.         */
  126.  
  127.         'username' => env('MAIL_USERNAME'),
  128.  
  129.         'password' => env('MAIL_PASSWORD'),
  130.  
  131.         /*
  132.         |--------------------------------------------------------------------------
  133.         | Sendmail System Path
  134.         |--------------------------------------------------------------------------
  135.         |
  136.         | When using the "sendmail" driver to send e-mails, we will need to know
  137.         | the path to where Sendmail lives on this server. A default path has
  138.         | been provided here, which will work well on most of your systems.
  139.         |
  140.         */
  141.  
  142.         'sendmail' => '/usr/sbin/sendmail -bs',
  143.  
  144.         /*
  145.         |--------------------------------------------------------------------------
  146.         | Markdown Mail Settings
  147.         |--------------------------------------------------------------------------
  148.         |
  149.         | If you are using Markdown based email rendering, you may configure your
  150.         | theme and component paths here, allowing you to customize the design
  151.         | of the emails. Or, you may simply stick with the Laravel defaults!
  152.         |
  153.         */
  154.  
  155.         'markdown' => [
  156.             'theme' => 'default',
  157.  
  158.             'paths' => [
  159.                 resource_path('views/vendor/mail'),
  160.             ],
  161.         ],
  162.  
  163.         /*
  164.         |--------------------------------------------------------------------------
  165.         | Log Channel
  166.         |--------------------------------------------------------------------------
  167.         |
  168.         | If you are using the "log" driver, you may specify the logging channel
  169.         | if you prefer to keep mail messages separate from other log entries
  170.         | for simpler reading. Otherwise, the default channel will be used.
  171.         |
  172.         */
  173.  
  174.         'log_channel' => env('MAIL_LOG_CHANNEL'),
  175.  
  176.     ];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement