<?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>attachement send in laravel Archives - scmGalaxy</title>
	<atom:link href="https://www.scmgalaxy.com/tutorials/tag/attachement-send-in-laravel/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.scmgalaxy.com/tutorials/tag/attachement-send-in-laravel/</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>Upload Document and send Mail in Laravel &#124; How to send attachment files to email using laravel ?</title>
		<link>https://www.scmgalaxy.com/tutorials/upload-document-and-send-mail-in-laravel-how-to-send-attachement-in-laravel-5-8/</link>
					<comments>https://www.scmgalaxy.com/tutorials/upload-document-and-send-mail-in-laravel-how-to-send-attachement-in-laravel-5-8/#respond</comments>
		
		<dc:creator><![CDATA[rajeshkumar]]></dc:creator>
		<pubDate>Thu, 08 Jul 2021 13:00:36 +0000</pubDate>
				<category><![CDATA[Laravel]]></category>
		<category><![CDATA[Websites]]></category>
		<category><![CDATA[attachement send in laravel]]></category>
		<category><![CDATA[laravel]]></category>
		<category><![CDATA[Laravel beginners]]></category>
		<category><![CDATA[mailtrap in laravel]]></category>
		<guid isPermaLink="false">https://www.scmgalaxy.com/tutorials/?p=6706</guid>

					<description><![CDATA[<p>In this tutorial im going to demonstrate how to upload document and send data via Email. Please follow some easy [&#8230;]</p>
<p>The post <a href="https://www.scmgalaxy.com/tutorials/upload-document-and-send-mail-in-laravel-how-to-send-attachement-in-laravel-5-8/">Upload Document and send Mail in Laravel | How to send attachment files to email using laravel ?</a> appeared first on <a href="https://www.scmgalaxy.com/tutorials">scmGalaxy</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph" id="64d2">In this tutorial im going to demonstrate how to upload document and send data via Email. Please follow some easy steps mentioned below.</p>



<h1 class="wp-block-heading" id="215d">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>



<p class="wp-block-paragraph" id="11ec">Let’s to create Controller</p>



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



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



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow"><p>Go to your controller&nbsp;<strong><em>SendEmailController</em></strong>&nbsp;and paste below code</p></blockquote>



<pre class="wp-block-preformatted">&lt;?php<br><br>namespace App\Http\Controllers;<br><br>use Illuminate\Http\Request;<br>use Illuminate\Support\Facades\Mail;<br>use App\Mail\SendMail;<br>use App\UploadImage;<br><br>class SendEmailController extends Controller<br>{<br><br>    function index()<br>    {<br>     return view('send_email');<br>    }<br>    public function store(Request $request){<br>        $request-&gt;validate([<br>        'name'=&gt;'required',<br>        'email' =&gt; 'required',<br>        'image'=&gt; 'required',<br>        ]);<br><br>        $resume = time() . '.' . $request['image']-&gt;getClientOriginalExtension();<br>        $imagesendbymailwithstore= new UploadImage();<br>        $imagesendbymailwithstore-&gt;name =  $request-&gt;name;<br>        $imagesendbymailwithstore-&gt;email = $request-&gt;email;<br>        $imagesendbymailwithstore-&gt;image = $resume;<br>        $imagesendbymailwithstore-&gt;save();<br><br>        // for mailling function working<br>        $imagesendbymailwithstore = array(<br>            'name' =&gt; $request-&gt;name,<br>            'email' =&gt; $request-&gt;email,<br>            'image' =&gt; 	$request-&gt;image,<br><br>        );<br>        Mail::to($imagesendbymailwithstore['email'])-&gt;send(new SendMail($imagesendbymailwithstore));<br>        $request['image']-&gt;move(base_path() . '/storage/app/public', $resume);<br>        return back()-&gt;with('success', 'Thanks for contacting us!');<br>    }<br>}</pre>



<p class="wp-block-paragraph" id="0523"><strong>Next create model and migration file so run below code.</strong></p>



<pre class="wp-block-preformatted">php artisan make:model UploadImage -m</pre>



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



<p class="wp-block-paragraph" id="a9d3">Next step go to your migration and and table</p>



<p class="wp-block-paragraph" id="855e"><strong>database\migrations\2020_10_23_070450_create_upload_images_table.php</strong></p>



<p class="wp-block-paragraph" id="184c">Add follow column name</p>



<pre class="wp-block-preformatted">$table-&gt;string('name');<br>$table-&gt;string('email');<br>$table-&gt;string('image');</pre>



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



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



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



<p class="wp-block-paragraph" id="1aa3">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/0*HVY7c4Qk1buFBt4H.png" alt=""/></figure>



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



<p class="wp-block-paragraph" id="914b">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="43e3">Then make a view page&nbsp;<strong>send_email.blade.php</strong></p>



<pre class="wp-block-preformatted">&lt;!DOCTYPE html&gt;<br>&lt;html&gt;<br> &lt;head&gt;<br>  &lt;title&gt;  send a mail with Attachment &lt;/title&gt;<br>  &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"&gt;&lt;/script&gt;<br>  &lt;link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" /&gt;<br>  &lt;script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"&gt;&lt;/script&gt;<br>  &lt;style type="text/css"&gt;<br>   .box{<br>    width:600px;<br>    margin:0 auto;<br>    border:1px solid #ccc;<br>   }<br>   .has-error<br>   {<br>    border-color:#cc0000;<br>    background-color:#ffff99;<br>   }<br>  &lt;/style&gt;<br> &lt;/head&gt;<br> &lt;body&gt;<br>  &lt;br /&gt;<br>  &lt;br /&gt;<br>  &lt;br /&gt;<br>  &lt;div class="container box"&gt;<br>   &lt;h3 align="center"&gt;send a mail with Attachment using laravel 5.8&lt;/h3&gt;&lt;br /&gt;<br>   @if (count($errors) &gt; 0)<br>    &lt;div class="alert alert-danger"&gt;<br>     &lt;button type="button" class="close" data-dismiss="alert"&gt;×&lt;/button&gt;<br>     &lt;ul&gt;<br>      @foreach ($errors-&gt;all() as $error)<br>       &lt;li&gt;{{ $error }}&lt;/li&gt;<br>      @endforeach<br>     &lt;/ul&gt;<br>    &lt;/div&gt;<br>   @endif<br>   @if ($message = Session::get('success'))<br>   &lt;div class="alert alert-success alert-block"&gt;<br>    &lt;button type="button" class="close" data-dismiss="alert"&gt;×&lt;/button&gt;<br>           &lt;strong&gt;{{ $message }}&lt;/strong&gt;<br>   &lt;/div&gt;<br>   @endif<br><br>&lt;form method="post" action="{{ route('sendemail.store') }}" enctype="multipart/form-data" role="form" class="form-horizontal" id="location"&gt;<br>    {{ csrf_field() }}<br>    &lt;div class="form-group"&gt;<br>     &lt;label&gt;Enter Your Name&lt;/label&gt;<br>     &lt;input type="text" name="name" class="form-control" value="" /&gt;<br>    &lt;/div&gt;<br>    &lt;div class="form-group"&gt;<br>     &lt;label&gt;Enter Your Email&lt;/label&gt;<br>     &lt;input type="text" name="email" class="form-control" value="" /&gt;<br>    &lt;/div&gt;<br><br>    &lt;div class="form-group"&gt;<br>            &lt;label for="resume" placeholder="(resume type *PDF*)"&gt;Document:&lt;span class="text-danger font-weight-bold"&gt;*&lt;/span&gt;&lt;/label&gt;<br>            &lt;input type="file" class="w-100 p-1" name="image" value="{{old('resume')}}"/&gt;<br>            &lt;label class="text-danger mt-1" &gt;(*File type- PDF &amp; Maximum size 1 MB*)&lt;/label&gt;<br>    &lt;/div&gt;<br>    &lt;div class="form-group"&gt;<br>     &lt;input type="submit" name="send" class="btn btn-info" value="Send" /&gt;<br>    &lt;/div&gt;<br>   &lt;/form&gt;<br><br>  &lt;/div&gt;<br> &lt;/body&gt;<br>&lt;/html&gt;</pre>



<p class="wp-block-paragraph" id="c912"><strong>Next step&nbsp;</strong>make one blade page resources/view/<strong>dynamic_email_template.blade.php</strong></p>



<pre class="wp-block-preformatted">&lt;p style="margin-left:10%;"&gt;First Name - &lt;b&gt;{{ $data['name'] }} &lt;/b&gt;&lt;/p&gt;<br>&lt;p style="margin-left:10%;"&gt;last Name - &lt;b&gt;{{ $data['email'] }}  &lt;/b&gt;&lt;/p&gt;<br><br><br>&lt;p&gt;It would be appriciative, if you gone through this feedback.&lt;/p&gt;</pre>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow"><p>Next one to create&nbsp;<strong><em>SendMail.php</em></strong>&nbsp;file run below code.</p></blockquote>



<pre class="wp-block-preformatted">php artisan make:mail SendMail</pre>



<p class="wp-block-paragraph" id="056b">Next step go to App\Mail\SendMail.php and paste below code</p>



<pre class="wp-block-preformatted">&lt;?php<br><br>namespace App\Mail;<br><br>use Illuminate\Bus\Queueable;<br>use Illuminate\Mail\Mailable;<br>use Illuminate\Queue\SerializesModels;<br>use Illuminate\Contracts\Queue\ShouldQueue;<br><br>class SendMail extends Mailable<br>{<br>    use Queueable, SerializesModels;<br>    public $imagesendbymailwithstore;<br>    /**<br>     * Create a new message instance.<br>     *<br>     * @return void<br>     */<br>    public function __construct($imagesendbymailwithstore)<br>    {<br>        $this-&gt;imagesendbymailwithstore = $imagesendbymailwithstore;<br>    }<br><br>    /**<br>     * Build the message.<br>     *<br>     * @return $this<br>     */<br>    public function build()<br>    {<br>        return $this-&gt;from('info@scmgalaxy.com')<br>        -&gt;subject('New image from Devops Team')<br>        -&gt;view('dynamic_email_template')<br>        -&gt;with('data', $this-&gt;imagesendbymailwithstore)<br>        -&gt;attach($this-&gt;imagesendbymailwithstore['image']-&gt;getRealPath(),<br>            [<br>                    'as' =&gt; $this-&gt;imagesendbymailwithstore['image']-&gt;getClientOriginalName(),<br>                'mime' =&gt; $this-&gt;imagesendbymailwithstore['image']-&gt;getClientMimeType(),<br>            ]);<br><br>    }<br>}</pre>



<p class="wp-block-paragraph" id="9452"><strong>Next define routes go to your routes/web.php file and paste below code.</strong></p>



<pre class="wp-block-preformatted">Route::get('sendemail','SendEmailController@index');<br>Route::post('sendemail.store','SendEmailController@store')-&gt;name('sendemail.store');</pre>



<p class="wp-block-paragraph" id="1c96">Now run below code and refresh your browser and fill form</p>



<pre class="wp-block-preformatted">php artisan servehttp://127.0.0.1:8000</pre>



<p class="wp-block-paragraph" id="6767">Now form look- like this</p>



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



<p class="wp-block-paragraph" id="34da">Thanks i hope its helpfull for you <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f64f.png" alt="🙏" class="wp-smiley" style="height: 1em; max-height: 1em;" /><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f64f.png" alt="🙏" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>
<p>The post <a href="https://www.scmgalaxy.com/tutorials/upload-document-and-send-mail-in-laravel-how-to-send-attachement-in-laravel-5-8/">Upload Document and send Mail in Laravel | How to send attachment files to email using laravel ?</a> appeared first on <a href="https://www.scmgalaxy.com/tutorials">scmGalaxy</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.scmgalaxy.com/tutorials/upload-document-and-send-mail-in-laravel-how-to-send-attachement-in-laravel-5-8/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<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>
