How to send mail using OctoberCms? - laravel

How to send Email in octobercms after form submission? i created a mail from backend mail template in octobercms the mail code is contact::form.
// $data has name and email
$to = System\Models\MailSettings::get('abc#gmail.com');
Mail::sendTo($to, 'contact::form', $data);
return true;
I'm getting this error :
\Components\System\Models\MailSettings' not found

Not sure what you're using MailSettings::get('abc#gmail.com') for, but you can remove that line and simply pass in the email address:
Mail::sendTo('abc#gmail.com', 'contact::form', $data);

Did you configure the mail system correctly to send mail?
What do you need the mail settings info for?
Remove that line. I believe that email will automatically be used unless you specify it in the Mail function.
I believe you need to add the Mail class (maybe input) to your component like so:
use Mail;
use Input;

Related

How to use Laravel IMAP for receive mailbox?

I am using laravel imap package for email setup for receive mailbox.
use this https://github.com/Webklex/laravel-imap#installation package, but i don't understand how it works or test. If anybody for help ?
Assuming you have already installed the package and set your environment variables in .env
Here is an example of how to get all unseen messages from Inbox. (check the API Docs for more available methods or classes)
https://github.com/Webklex/laravel-imap#documentation
$oClient = Client::account('default'); // defined in config/imap.php
$oClient->connect();
// get all unseen messages from folder INBOX
$aMessage = $oClient->getUnseenMessages($oClient->getFolder('INBOX'));
foreach ($aMessage as $oMessage) {
// do something with the message
}

Preview Laravel Mail before sending

I want to edit my mail and change everything, if I want, as shown here.
Ive imported my file and created a test route to view the page:
use Illuminate\Mail\Markdown;
Route::get('/mail/html', function () {
$markdown = new Markdown(view(), config('mail.markdown'));
return $markdown->render('vendor.mail.html.message'); // or ..markdown.message
});
However, Im having variable errors for #slot. How to view my change/see what the mail looks like before sending? Another package for that?
Thanks
To preview your email in browser please add below code to route
Route::get('preview-notification', function () {
$markdown = new \Illuminate\Mail\Markdown(view(), config('mail.markdown'));
$data = "Your data to be use in blade file";
return $markdown->render("path-of-your-templete-blade-file", $data]);
});
and you will be access your templete using
http://your-application-url/preview-notification
This is the recommended way by the Laravel community
kunal has a nice quick solution and that's how I used to do it. But now I use mailtrap.io to test emails because it allows you to replicate the whole process of sending an email.
Create a (free) account with mailtrap.io.
Add your mailtrap username and password in .env file.
By the way, Laravel is already configured to use mailtrap by default, so it is their recommended way to test emails.
Watch how Jeffrey Ways does it in his lesson:
Laravel 5.4 From Scratch: Sending Email
https://laracasts.com/series/laravel-from-scratch-2017/episodes/26
If you want to test in locally. You can put echo command in blade file at end and put die; this way you can test.Suppose you have test-email.blade.php
test-email.blade.php // file name
This is tets mail
<?php echo "test"; die; ?>
Hope it helps!

Send a email in Grails 3 with an image in it

I am trying to send an image within an email when in Development for a Grails 3 project. The email is sent through AWS email service. I have tried the img tag with absolute equal to true but have been unable to succeed in seeing the image in the email? Using asset-pipeline so it might be something related to that.
How do you achieve seeing the image in a email?
I used asynchronous send mail grails plugin for mail with image code part as follows:
File f = new File("IMG.jpg")
asynchronousMailService.sendMail {
from "senderMailID"
to "recipientsMailID"
bcc "BCCMailID"
subject "subject"
html "html code"
inline 'YourImageName', 'image/jpg', f
}
Then your HTML codes contains
<img src="cid:YourImageName" style="height: 60px">
I hope this helps you!
I would recommend you to use this grails plugin sending image or text etc. attachment through AWS.
http://grails-aws.github.io/grails-aws/1.7.5.0/guide/3%20Amazon%20Simple%20Email%20Service%20(AWS%20SES).html
And if your done with AWS mail configuration then you can use mail service like this:
Mail {
to "email#gmailcom"
subject "testing emails with one attachment"
body "..."
attach "/users/website/images/file1.jpg"
}
Hope this will help you!

Unable to get complete URL in Password Reset in Laravel

I am using the Laravel 5 ResetsPasswords trait to implement password reset. In the file resources/views/emails/password.blade.php., I have the following code.
Click To Reset Password
I am using a queue to send the email to the user. When the user clicks the link received in email, I get something like below:
http://localhost/password/reset/2aafe5381baa67f9d1fe2f476c0f1395b21e71fafe181b2980fb838fc9e0b2fc
I was rather expecting:
http://localhost/oap/public/password/reset/2aafe5381baa67f9d1fe2f476c0f1395b21e71fafe181b2980fb838fc9e0b2fc
Why is oap/public/ not in the url? I have used the url() function in other views and they have worked just well except for this email view where I am using queue to send the message. When a queue is not used to send the message, the link is okay. Any idea how I can resolve this issue.
Use URL::to. Like,
Click To Reset Password
for the url helpers it will generate the full path for your inputs
{{ url('/password/reset/'.$token) }}
will generate
http://localhost/password/reset/2aafe5381baa67f9d1fe2f476c0f1395b21e71fafe181b2980fb838fc9e0b2fc
and
{{ url('/oap/public/password/reset/'.$token) }}
will generate
http://localhost/oap/public/password/reset/2aafe5381baa67f9d1fe2f476c0f1395b21e71fafe181b2980fb838fc9e0b2fc
you can also get around this
Route::get('oap/public/password/reset/{confirmcode}', ['as' => 'resetpassword', 'HomeController#resetmethod']);
then using this like that
{{route('resetpassword', ['confirmcode' => $token])}}

Best PHP mailing library for Codeigniter-2

Iam using CI-2 default mail class for sending emails. But it is not sending HTML based emails properly.
Can someone tell me good email sending libraries for CI2.
Thanks in advance
Try to configure the library to send html emails
$config['mailtype'] = 'html';
$this->email->initialize($config);
gmail and HTML content is a common problem; solutions have been suggested in the official CI forum with references to using Swift Mailer instead.
There is another solution I've found for poor HTML / Email Support.
Open up the Email Class:
System/Libraries/Email.php
Around Line 51 You'll see
var $send_multipart = TRUE;
Set this to FALSE and try again. I find CI's email library to be very good.

Resources