<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>sendemail Archives - scmGalaxy</title>
	<atom:link href="https://www.scmgalaxy.com/tutorials/tag/sendemail/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.scmgalaxy.com/tutorials/tag/sendemail/</link>
	<description>A Platform for Software Engineers</description>
	<lastBuildDate>Wed, 13 Apr 2022 16:33:34 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.1</generator>
	<item>
		<title>How to Send email with Attachement in Laravel 5.8</title>
		<link>https://www.scmgalaxy.com/tutorials/how-to-send-email-with-attachement-in-laravel-5-8/</link>
					<comments>https://www.scmgalaxy.com/tutorials/how-to-send-email-with-attachement-in-laravel-5-8/#respond</comments>
		
		<dc:creator><![CDATA[rajeshkumar]]></dc:creator>
		<pubDate>Wed, 07 Jul 2021 12:48:31 +0000</pubDate>
				<category><![CDATA[Laravel]]></category>
		<category><![CDATA[Websites]]></category>
		<category><![CDATA[attachement send in laravel]]></category>
		<category><![CDATA[laravel]]></category>
		<category><![CDATA[mailtrap in laravel]]></category>
		<category><![CDATA[sendemail]]></category>
		<guid isPermaLink="false">https://www.scmgalaxy.com/tutorials/?p=6701</guid>

					<description><![CDATA[<p>In this tutorial i’m going to describe how to send attachement in laravel, please follow some easy steps define below. [&#8230;]</p>
<p>The post <a href="https://www.scmgalaxy.com/tutorials/how-to-send-email-with-attachement-in-laravel-5-8/">How to Send email with Attachement in Laravel 5.8</a> appeared first on <a href="https://www.scmgalaxy.com/tutorials">scmGalaxy</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph" id="caf8">In this tutorial i’m going to describe how to send attachement in laravel, please follow some easy steps define below.</p>



<h1 class="wp-block-heading" id="2d54">First let’s go to install laravel project</h1>



<pre class="wp-block-preformatted">composer create-project laravel/laravel learning-project "5.8.*"</pre>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow"><p><em>lets go to&nbsp;</em><strong><em>.env folder</em></strong><em>&nbsp;and put database name and connect to database.</em></p></blockquote>



<pre class="wp-block-preformatted">DB_CONNECTION=mysql<br>DB_HOST=127.0.0.1<br>DB_PORT=3306<br>DB_DATABASE=learning-project<br>DB_USERNAME=root<br>DB_PASSWORD=</pre>



<figure class="wp-block-image"><img decoding="async" src="https://miro.medium.com/max/700/0*rI2OSx5279q_tLjh.png" alt=""/></figure>



<h1 class="wp-block-heading" id="8ad5">Now migrate the table</h1>



<pre class="wp-block-preformatted">php artisan migrate</pre>



<p class="wp-block-paragraph" id="7702">Create a Mailable class first you have to create an account in mailtrap or click this url&nbsp;<a href="https://mailtrap.io/">https://mailtrap.io/</a>&nbsp;after create account you have to copy Username: XXXXXXXXX and password: XXXXXXXXXX and put in .env file see pic</p>



<figure class="wp-block-image"><img decoding="async" src="https://miro.medium.com/max/700/1*MNJLyP2Na96LVJiWE2DbAQ.png" alt=""/></figure>



<figure class="wp-block-image"><img decoding="async" src="https://miro.medium.com/max/700/1*CZvpovcU2BRhPOjmDJBq3w.png" alt=""/></figure>



<p class="wp-block-paragraph" id="a7fe">Now we are ready for make mailable class for this we have to go teminal and write following</p>



<p class="wp-block-paragraph" id="b5dc">Let’s go to create controller</p>



<pre class="wp-block-preformatted">php artisan make:controller PDFController</pre>



<p class="wp-block-paragraph" id="59ca">Go to your PDF controller file and paste below code</p>



<pre class="wp-block-preformatted">&lt;?php<br>  <br>namespace App\Http\Controllers;<br>use Log;<br>use PDF;<br>use Mail;<br>  <br>class PDFController extends Controller<br>{<br>    /**<br>     * Write code on Method<br>     *<br>     * @return response()<br>     */<br>    public function index()<br>    {<br>        $data["email"] = "laravelamit@gmail.com";<br>        $data["title"] = "From DevOpsSchool.com";<br>        $data["body"] = "This is Demo";<br> <br>        $files = [<br>            public_path('files/yit-brochure.pdf'),<br>            public_path('files/laravel.png'),<br>        ];<br>        // log::info('mail aa rha hai');<br>        Mail::send('emails.myTestMail', $data, function($message)use($data, $files) {<br>            $message-&gt;to($data["email"], $data["email"])<br>                    -&gt;subject($data["title"]);<br> <br>            foreach ($files as $file){<br>                $message-&gt;attach($file);<br>            }<br>            <br>        });<br> <br>        dd('Mail sent successfully');<br>    }<br>}</pre>



<p class="wp-block-paragraph" id="10ef">Next to create view files</p>



<pre class="wp-block-preformatted">resources/views/emails/myTestMail.blade.php</pre>



<p class="wp-block-paragraph" id="ffdd">Go to&nbsp;your myTestMail.blade file and paste below code</p>



<pre class="wp-block-preformatted">&lt;!DOCTYPE html&gt;<br>&lt;html&gt;<br>&lt;head&gt;<br>    &lt;title&gt;Laravel Amit&lt;/title&gt;<br>&lt;/head&gt;<br>&lt;body&gt;<br>    &lt;h1&gt;{{ $title }}&lt;/h1&gt;<br>    &lt;p&gt;{{ $body }}&lt;/p&gt;<br>     <br>    &lt;p&gt;Thank you&lt;/p&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;</pre>



<p class="wp-block-paragraph" id="36b8">And lastone go to Routes/web.php and paste below code.</p>



<pre class="wp-block-preformatted">&lt;?php<br><br>use Illuminate\Support\Facades\Route;<br>use App\Http\Controllers\PDFController;<br><br>/*<br>|--------------------------------------------------------------------------<br>| Web Routes<br>|--------------------------------------------------------------------------<br>|<br>| Here is where you can register web routes for your application. These<br>| routes are loaded by the RouteServiceProvider within a group which<br>| contains the "web" middleware group. Now create something great!<br>|<br>*/<br><br>Route::get('/', function () {<br>    return view('welcome');<br>});<br><br>Auth::routes(['verify' =&gt; true]);<br><br>Route::get('/home', 'HomeController@index')-&gt;name('home');<br>Route::get('/send-email-pdf', 'PDFController@index')-&gt;name('sendemail');</pre>



<p class="wp-block-paragraph" id="31e4">Now refresh your browser and check.</p>



<figure class="wp-block-image"><img decoding="async" src="https://miro.medium.com/max/700/1*3B7hjVsIfyqF3AtP0tT8sA.png" alt=""/></figure>



<figure class="wp-block-image"><img decoding="async" src="https://miro.medium.com/max/700/1*MQ8yHHi4WRity-MyXwUcWQ.png" alt=""/></figure>



<p class="wp-block-paragraph" id="f6a6">Thanks …</p>
<p>The post <a href="https://www.scmgalaxy.com/tutorials/how-to-send-email-with-attachement-in-laravel-5-8/">How to Send email with Attachement in Laravel 5.8</a> appeared first on <a href="https://www.scmgalaxy.com/tutorials">scmGalaxy</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.scmgalaxy.com/tutorials/how-to-send-email-with-attachement-in-laravel-5-8/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
