Home Backend Development PHP Tutorial laravel5.4 uses 163 mailbox to send emails

laravel5.4 uses 163 mailbox to send emails

Sep 26, 2017 am 09:50 AM
laravel5.4 send mail

Sending emails is an essential requirement that we encounter in daily development. The following article mainly introduces you to the steps of using laravel5.4 to send emails using the 163 mailbox. The article introduces it through sample codes and pictures. Very detailed, friends in need can refer to it.

Preface

In fact, sending an email is not difficult, rather it is quite simple. This article will introduce in detail about laravel5.4 using 163 email to send The relevant content of the email is shared for everyone’s reference and study. I won’t go into details below, let’s take a look at the detailed introduction.

1. First, register an account with 163 now and set it up as shown below


##The authorization code is very important. Please remember it carefully. You will configure it in laravel’s .env later~~


2. If you have done all the above, then the next step is to configure .env


MAIL_DRIVER=smtp

MAIL_HOST=smtp.163.com

MAIL_PORT=465

MAIL_USERNAME=你的账号@163.com

MAIL_PASSWORD=你的客户端授权密码

MAIL_FROM_ADDRESS=你的账号@163.com

MAIL_FROM_NAME=账号名

MAIL_ENCRYPTION=ssl
Copy after login

3. Then continue The next step is to configure routing and write the method of sending emails on the controller


Route::get('mail/send','CommonController@send');
Copy after login

Write this on any controller you want send method:



public function send()

{

$name='学院君';

$flag= Mail::raw('你好,我是PHP程序!',function($message) {

$to='你的qq邮箱@qq.com';

$message->to($to)->subject('纯文本信息邮件测试');

});

if(!$flag){

echo '发送邮件成功,请查收!';

}else{

echo '发送邮件失败,请重试!';

}

//以上是纯文本,下面则是附带文件发送

//  $flag = Mail::send('emails.test',['name'=>$name],function($message){

//   $to = '你的qq邮箱@qq.com';

//   $message->to($to)->subject('text');

//   // $filePath = 'storage/exports/'.iconv('UTF-8', 'GBK', '学生成绩').'.xls';

//   $attachment = storage_path('app/files/test.txt');

//   //在邮件中上传附件

//   $message->attach($attachment,['as'=>'text.txt']);

//  });

//下面是发送邮件附带图片的

//  $imgPath = 'http://laravelacademy.org/wp-statics/images/carousel/LaravelAcademy.jpg';

//  $flag = Mail::send('emails.test',['name'=>$name,'imgPath'=>$imgPath],function($message){

//   $to = '你的qq邮箱@qq.com';

//   $message ->to($to)->subject('网络图片测试');

//  });

//  if(!$flag){

//   echo '发送邮件成功,请查收!';

//  }else{

//   echo '发送邮件失败,请重试!';

//  }

}
Copy after login

Okay, the next step is to access the routing yourself to get the results you want~~~~~

PS: The key point is to get the error reporting process right. Basically, if you follow the steps, there won’t be any big problems. However, the most important thing is what I use. It is done on Ubuntu16.04 system. The permission issues should be solved first, so I suggest giving permission first and opening the command line in your directory: sudo chmod 777 -R ./

Okay, the next step is to solve the problem of not being able to connect to the 163 NetEase mailbox. The method I can give is to add two lines of code to line 263 of StreamBuffer.php:



$options['ssl']['verify_peer'] = FALSE;

$options['ssl']['verify_peer_name'] = FALSE;
Copy after login

Basically follow the above steps and you can get it done~~~

The above is the detailed content of laravel5.4 uses 163 mailbox to send emails. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Outlook emails lost from control panel in Windows 11 Outlook emails lost from control panel in Windows 11 Feb 29, 2024 pm 03:16 PM

Is the Outlook mail icon missing from Windows 11's Control Panel? This unexpected situation has caused confusion and concern among some individuals who rely on OutlookMail for their communication needs. Why don't my Outlook emails show up in Control Panel? There may be several possible reasons why there are no Outlook mail icons in Control Panel: Outlook is not installed correctly. Installing Office applications from the Microsoft Store does not add the Mail applet to Control Panel. The location of the mlcfg32.cpl file in Control Panel is missing. The path to the mlcfg32.cpl file in the registry is incorrect. The operating system is not currently configured to run this application

Word mail merge prints blank page Word mail merge prints blank page Feb 19, 2024 pm 04:51 PM

If you find that blank pages appear when printing a mail merge document using Word, this article will help you. Mail merge is a convenient feature that allows you to easily create personalized documents and send them to multiple recipients. In Microsoft Word, the mail merge feature is highly regarded because it helps users save time manually copying the same content for each recipient. In order to print the mail merge document, you can go to the Mailings tab. But some Word users have reported that when trying to print a mail merge document, the printer prints a blank page or doesn't print at all. This may be due to incorrect formatting or printer settings. Try checking the document and printer settings and make sure to preview the document before printing to ensure the content is correct. if

Say goodbye to the Remote Mail Slot protocol in Windows 11 Say goodbye to the Remote Mail Slot protocol in Windows 11 Apr 14, 2023 pm 10:28 PM

We've been talking lately about the many features Microsoft plans to add to its latest operating system, Windows 11. But don't think that Microsoft will add nothing and take nothing back. In fact, the software giant started removing quite a few old features. After announcing plans to decommission MSDT functionality ahead of the release of Windows 12, a Redmond developer has more bad news. We are actually talking about remote mail slot legacy tool. Trust us when we say you actually want to know this. Microsoft has started deprecating this feature in build 25314. We are sure you remember that just a few days ago, Microsoft released build 25314 in its new canary channel. The above version contains many new features

How to Fix Outlook Email Stuck in Outbox Issue How to Fix Outlook Email Stuck in Outbox Issue May 01, 2023 am 10:01 AM

Recently, many users have reported the issue of Outlook emails getting stuck in the outbox. Even after several attempts to send the email, the issue was not resolved. When you see this issue and check your outbox folder, the message will be stuck there. Possible reasons for emails getting stuck in Outlook outbox: The attachments in the email exceed the size limit, which slows down the sending process. Outlook account authentication issues with mail server Incorrect send/receive settings in Outlook or mail server offline Outlook. Outlook data files are being used by some other software. Antivirus software scans outgoing emails. If this problem has been bothering you and you are unable to send an email

PHP sends emails asynchronously: avoid long waits for emails to be sent. PHP sends emails asynchronously: avoid long waits for emails to be sent. Sep 19, 2023 am 09:10 AM

PHP sends emails asynchronously: avoid long waits for emails to be sent. Introduction: In web development, sending emails is one of the common functions. However, since sending emails requires communication with the server, it often causes users to wait for a long time while waiting for the email to be sent. In order to solve this problem, we can use PHP to send emails asynchronously to optimize the user experience. This article will introduce how to implement PHP to send emails asynchronously through specific code examples and avoid long waits. 1. Understanding sending emails asynchronously

How to send files to others on TikTok? How to delete files sent to others? How to send files to others on TikTok? How to delete files sent to others? Mar 22, 2024 am 08:30 AM

On Douyin, users can not only share their life details and talents, but also interact with other users. In this process, sometimes we need to send files to other users, such as pictures, videos, etc. So, how to send files to others on Douyin? 1. How to send files to others on Douyin? 1. Open Douyin and enter the chat interface where you want to send files. 2. Click the "+" sign in the chat interface and select "File". 3. In the file options, you can choose to send pictures, videos, audio and other files. After selecting the file you want to send, click "Send". 4. Wait for the other party to accept your file. Once the other party accepts it, the file will be transferred successfully. 2. How to delete files sent to others on Douyin? 1. Open Douyin and enter the text you sent.

PHP email tracking function: understand user behavior and feedback on emails. PHP email tracking function: understand user behavior and feedback on emails. Sep 19, 2023 am 08:51 AM

PHP email tracking function: understand user behavior and feedback on emails In modern society, email has become an indispensable part of people's daily life and work. For businesses, sending emails is one of the important ways to communicate with customers and promote products or services. However, after an email is sent, how do we know whether it was received, read, or how the user reacted to the content of the email? At this time, the email tracking function becomes particularly important. The email tracking function can help us understand user behavior and feedback on emails

How to set Gmail to delete instead of archive in the Mail app on iPhone and iPad How to set Gmail to delete instead of archive in the Mail app on iPhone and iPad Apr 13, 2023 pm 02:34 PM

Have you noticed that when you try to delete a message in Gmail on iOS, you only see the archive option? Read on to learn how to delete Gmail on iPhone without archiving it in the Mail app. The setting to change the default option for archiving Gmail emails using the Mail app on iPhone and iPad is completely hidden in Settings, but it can be changed quickly once you know where to go. Keep in mind that this tutorial is for people using Gmail through the Apple Mail app on iPhone and iPad. Another option is to use the Gmail app on your iPhone/iPad. you even

See all articles