When the user of my website used the contact form, i want send a mail with the confirmation to the user and send to me other message with the created ticket.
I´m using Laravel 5.2 + Mailgun
But only sent the last mail to my email hello#frikinow.com, the user confirmation email is not sent.
Laravel not returns any error. This is my code:
// for the client mail
Mail::send('emails.success_email', ['name' => Input::get('nombre'), 'content' => $content], function ($message)
{
$message->subject('FrikiNow ha recibido su consulta');
$message->from('hello#frikinow.com', 'FrikiNow Support');
$message->to(Input::get('email'));
});
// for me
Mail::send('emails.ticket_email', ['email'=> Input::get('email'),'name' => Input::get('nombre'), 'content' => Input::get('mensaje'),'mobile_phone' =>Input::get('telefono')], function ($message)
{
$message->subject('Ticket de Cliente: '.Input::get('asunto'));
$message->from('hello#frikinow.com', Input::get('nombre'));
$message->to('hello#frikinow.com');
});
How I can send two different emails at once?
You may add CC header
Im not full aware of MailGun API, but you can try this:
$message->cc('email#example.com'); //Copy of the message goes to this email
Related
The Laravel mail() function works OK when I send emails to Gmail accounts from my company mail (sales#stopshoprei.com). But When I send it to my own company email domain accounts like 'info#360synergytech.com' from the same mail (sales#stopshoprei.com) it gives the error.
(Expected response code 354 but got code "503", with message
"503-All RCPT commands were rejected with this error:\r\n503-No Such
User Here\r\n503 Valid RCPT command must precede DATA\r\n"",).
Controller
public function mailSenderIntegration(Request $request)
{
$data = $request->input();
$crm_payment = CrmPayment::where('unique_Id', $data["unique_Id"])->first();
//data for client mail
$firstName = $crm_payment->first_name;
$services_choosed = $crm_payment->requested_services;
$services_choosed = json_decode($services_choosed);
$count_services = count($services_choosed);
$client_email = $crm_payment->email;
$mailData = [
'name' => $firstName,
'body' => "There's an integration you need which is not listed at
futureflippercrm.stopshoprei.com.
Our sales person would contact you soon for requirements.",
];
//Mail client
Mail::to($client_email)
->send(new mailTempInt($mailData));
}
.env
MAIL_DRIVER=smtp
MAIL_HOST=mail.stopshoprei.com
MAIL_PORT=465
MAIL_USERNAME=sales#stopshoprei.com
MAIL_PASSWORD=*******
MAIL_ENCRYPTION=ssl
MAIL_FROM_ADDRESS=sales#stopshoprei.com
MAIL_FROM_NAME="Future Flipper CRM"
I tried to change port but same result. Is this an issue with domain?
How to change the default message stream of Postmark mailer while using Laravel mail.
I've tried with the below code on build() in the mail MarketingMail.php.
But it isn't working.
Searched for the solution and can't find the correct solution.
MarketingMail.php
$date = date('d M Y',strtotime("today"));
$this->subject("Visa Rates ".$date)->markdown('Mails.visa.marketing',['data'=>$this->data]);
$this->withSymfonyMessage(function (Email $message) {
$message->getHeaders()->addTextHeader(
'X-PM-Message-Stream', 'broadcast'
);
});
return $this;
I have a function to send email to customer for every new registration. and my client want to record any unsuccessfull email sent (i.e if email address is wrong).
i try using try-cacth and mail::failure.
try{
Mail::send('mail.mail', compact(''), function ($message) use ($) {
$message->from();
$message->subject();
$message->to();
});
}
catch(\Swift_TransportException $e){
}
mail:failures
if (Mail::failures()) {
echo ('error');
}
but this working if network failure, such as email host is down. how to record/get info if email wasnt delivered because email address/domain not found.
i get this info in email if email wasnt delivered. but how to record it the ddetails into database.
Address not found
Your message wasn't delivered to asna#asmas.cl because the domain asmas.cl couldn't be found. Check for typos or unnecessary spaces and try again.
look my below code gets a json resposnse after sending an sms, your system should also get a response json after sending the email. The json carrys a set of data. check the particular data response you wish for and update it accordingly on your table.
$responseJson = json_decode($response, true);
// data returned --> [{"status":"200","response":"success","message_id":82682342,"recipient":"4113122"}]
$status = ($responseJson[0])['status'];
$responseDescripition = ($responseJson[0])['response'];
Log::info('API status >>>>> ' . $status);
Log::info('API Response Description >>>>> ' . $responseDescripition);
if (($responseJson[0])) {
DB::table('mess')->where('id', $request->input('template'))
->update([
'sentstatus' => '1',
'status' => $status,
'responsecode' => $responseDescripition,
'sent_on' => \Carbon\Carbon::now(),
]);
}
I have a function in my controller which saves messages from users, first it saves message into database than it sends email to that user's mail address and than it returns json response to the sender.
Problem: sometimes it takes too long for email to be sent, and the sender has to wait long time for the response, or sometimes email is not even sent (due to some smpt problems etc.) and it triggers an error, however I don't really care that much if email is sent or not, most important that message is saved to the database.
What I'm trying to achieve:
I want to save message to the database, ->
immediately after that send response to the sender, ->
and only after run Mail::send();
so run Mail::send() after controller returns json to the sender, so the sender will receive a positive response regardless of how Mail::send() performs
$message = new MessageDB;
$message->listing_id = e(Input::get('listing_id'));
$message->user_id = $listing->User->id;
$message->name = e(Input::get('name'));
$message->mobile = e(Input::get('mobile'));
$message->message = e(Input::get('message'));
if ($message->save()) {
Mail::send('emails.message', ['user' => 'Jon Doe','message' => $message], function($m) use($listing){
$listing_agent = $listing->Agent;
if ($listing->agent == null) {
$mail_to = $listing->User->email;
$name = '';
}else{
$mail_to = $listing->Agent->email;
$name = $listing->Agent->first_name.' '.$listing->Agent->second_name;
}
$m->to($mail_to)->subject('new message from company.com');
});
return ['success' => 1, 'message' => 'messasge has been sent'];
You can use Mail Queueing functions of Laravel. Here's the Link
Mail::queue('emails.welcome', $data, function($message) {});Queue mail for background Sending.
Mail::later(5, 'emails.welcome', $data, function($message){});Define Seconds after which mail will be sent.
Here's the code I'm using to send an e-mail to multiple recipients:
$recipients = ['myoneemail#esomething.com', 'myother#esomething.com','myother2#esomething.com'];
Mail::send(['admin.emails.email.html', 'admin.emails.email.text'], ['content' => $request->input('message')],
function ($message) use ($request, $recipients) {
$message
->to($recipients)
->subject($request->input('subject'))
->replyTo('xxx#xxx.com', 'Me');
});
I'm using Mailtrap.io as a fake inbox to catch the e-mails. I only get the mail sent to "myoneemail#esomething.com", not the other ones.
But why ?