Send emails from different senders with Laravel proyect - laravel

Ive been doing some research about the best way to configure a contact us function with Laravel. I just want the clients of my website can email me their questions.
So is safe without using mailables? like;
Mail::plain('Hello {{ $user }}, welcome to Laravel!', ['user' => 'John Doe'], function ($message) {
$message
->to(...)
->subject(...);
});
Or would be a way to use pex mailgun but with different senders each time. Sound weird I know, but Im lost. If that isnt posible, I could use the same from but add an email input in the form so I'd know who is sending the email.
I hope you can send me some light.
Thanks in advance!

Related

Laravel send email with multiple senders

I have a Laravel application that send two different kind of emails from different senders. One for the users and other one for the admins.
The emails for the admins works fine, i'm using smtp gmail.
How can I send the other type of emails using different sender? Thank you.
You can use the from() function in the mailable or the facade (if Mailables aren't in your version of Laravel):
Docs: https://laravel.com/docs/5.7/mail#configuring-the-sender

Email sent via Sendgrid getting late delivered to customers

We are using SendGrid to send email to customers once they get registered on our website.
We have two portals:
One is live, and another is a test portal.
When customers are signing up in the live portal, the email is getting delayed about 5 minutes to reach the customer, but when the customer is receiving the mail after 5 minutes, the time of receiving mail is showing exactly the same time at which customer did signup.
Whereas in the test portal, emails are getting delivered at the correct time.
The code in both portals are totally the same.
This problem is happening with only Gmail, but I am not able to find out why emails are getting delivered late in live portal.
If anyone faced this same problem before, can you please guide me to solve this?
Here below is the code to send email
if($input['email']!= ''){
$email = $input['email'];
$username = Input::get('name');
$password = Input::get('password');
if($userdata->email != '')
{
Mail::send('emails.templates.activation',
array('username' => $username,'customer'=>$customer,'code'=>$code), function($message) use ($userdata) {
$message->from('support#buynuse.net', 'Buynuse');
$message->to($userdata->email, $userdata->username)->subject('Please activate your new Buynuse account');
});
}
echo 'email';exit;
}

Use Laravel Notification for Email Verification

You can send notifications via email like this in Laravel...
<?php
public function toMail($notifiable)
{
$url = url('/invoice/' . $this->invoice->id);
return (new MailMessage)
->greeting('Hello!')
->line('One of your invoices has been paid!')
->action('View Invoice', $url)
->line('Thank you for using our application!');
}
However, is it a good approach (in software design) to use this feature to send verification emails upon user registration?
yes, it is a fast way to send notification, we register a greeting, a line of text, a call to action, and then another line of text. These methods provided by the MailMessage object make it simple and fast to format small transactional emails. The mail channel will then translate the message components into a nice, responsive HTML email template with a plain-text counterpart.
you can also formatting the notification in better way for example:
Error Messages
Customizing The Recipient
Customizing The Subject
Customizing The Templates
reference Laravel Reference
Laravel Notifications is an all new feature coming to Laravel 5.3 that allows you to make quick notification updates through services like Slack, SMS, Email, and more.
This is great. Notifications are so simple and robust, you may no longer find yourself needing to use any other notification tool (mail, Slack SDK directly, etc.)—especially when you see how many custom notification channels the community has created. It's bonkers.
As always, with great power comes great responsibility; make sure you're being careful with your users' time and attention and you don't go overboard with the notifications.
So, go forth. Notify.

How to use Twilio StatusCallback in codeigniter

I have looked through all documentation and I cannot find a way to receive my StatusCallback from my Codeigniter app and need some help please. I have an app that sends out an sms to a client. I just need Twilio to return the status as it updates. My app will get the status as soon as it queues up but I can't get a response with any updates. Thanks in advance for any help.
Controller:
$client = new Services_Twilio($this->AccountSid, $this->AuthToken);
$client->account->messages->sendMessage($from, $to, $body_message, NULL, array("StatusCallback" => $callbackurl));
Like I said, everything is working great except the StatusCallback. I searched on this topic and I just see a bunch of confusion and not many people getting it to work. Please let me know if you need any further information.
Thanks!!

How to know mail send or not send in laravel and which recipient is not getting it?

Hi I am using the bellow function, can you please guide me how can I use Mail::failures(); in it
Mail::send('emails.caregiversetprimary', $templateArray, function($message)use($email)
{
$message->to($email, 'username')->subject('my subject');
});
Mail::failures(); < ====== this gives me black array as I have used wrong email
I am using laravel 4.1
tl;dr
You can know which recipients the email has been sent to but no which recipients have received it.
details
You need a better understanding of how mail servers work. From a Laravel point of view, there is no way (or at least not a simple one*) of knowing which recipients got the email. Its a matter of how mail protocol works. You may know which recipients the message has been sent to but no which recipients actually got it.
With Mail::failures() you get a list of recipients to which Laravel tried to send the email but it failed on actually sending it. But again, if it has been sent there is no straightforward way to known if the mail reached their inbox or no.
*If you happend to use Mailgun, Mandrill or any other 3rd party software then you are not dealing with a mail server 'per se' but with an API service. May be you could check the mail service provider documentation to research if they perform any kind of delivery tracking that you can programatically check.

Resources