From and to address in same in gmail - laravel

I am sending mail with laravel. Mail is in gmail but from and to address is same in gmail why ? i am confused.
env
MAIL_MAILER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=abc2020
MAIL_PASSWORD=Abc#123
MAIL_ENCRYPTION=tls
\Mail::send('invoice', array(
'name' => $user_details->name,
'email' => $user_details->email,
'subject' =>'Order is placed',
), function($message) use ($req){
$message->from($req->email,'Order');
$message->to('abc2020#gmail.com')->subject('Order is Placed');
});
Invoic is send in email but from address is same as to address
from:abc2020#gmail.com
to:abc2020#gmail.com
What is changes in code so that from address is from $req->email..

Google rewrites the From and Reply-To headers in messages you send via its SMTP service to values that relate to your Gmail account. So changing it in the codebase will make no difference.
If you need to modify the From and/or Reply-To addresses, you need to consider alternative SMTP services.

Related

Not Getting Email using Gmail smtp on live server Laravel

I am on Laravel 5.6 and my application working well.
I am using Gmail SMTP for mail services.
here is my .env file.
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=username#gmail.com
MAIL_PASSWORD=password
MAIL_ENCRYPTION=tls
I have already Turned ON Less secure apps in Gmail also turned ON 2 step verification.
From localhost, the mail system working like charm and I am getting all emails from Gmail SMTP.
But From Live Server, I am not getting any Emails and even there is no error popup.
My Host is a 000webhost free account because I am testing my Application.
so I read forums in 000webhost and change "SET MX RECORD " to "GOOGLE'S MX RECORD".
Now I am getting this error while sending any mail.
Expected response code 250 but got code "530", with message "530-5.5.1
Authentication Required. Learn more at 530 5.5.1
https://support.google.com/mail/?p=WantAuthError k142sm4568022ywa.67 -
gsmtp "
Please help!
Thanks in advance.
try changing your config/mail.php to your current credentials:
'driver' => env('MAIL_DRIVER', 'smtp'),
'host' => env('MAIL_HOST', 'smtp.gmail.com'),
'port' => env('MAIL_PORT', 587),
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('MAIL_USERNAME', 'username#gmail.com'),
'password' => env('MAIL_PASSWORD', 'password'),
Please allow access to less secure app from your google account following these steps:
Go to your Google Account.
On the left navigation panel, click Security.
On the bottom of the page, in the Less secure app access panel, click Turn on access.
If you don't see this setting, your administrator might have turned off less secure app account access.

How to set up mailgun with laravel 5.7?

I am trying to set up mail sending with mailgun on my deployed laravel application. I am able to send email verification emails, but I can't send to my email. For example:
Notification::route('mail', 'admin#mywebsite.org')
->notify(new Feedback($user->email, $subject, $message));
When I was using mailtrap.io to test my mail sending it worked perfectly.
My .env file looks like this:
MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailgun.org
MAIL_PORT=587
MAILGUN_SECRET=key-<key>
MAIL_USERNAME=postmaster#sandbox<somenums>.mailgun.org
MAIL_PASSWORD=<mypass>
MAIL_ENCRYPTION=tls
When I try to send the email it brings this error: Expected response code 250 but got code "554", with message "554 Sandbox subdomains are for test purposes only. Please add your own domain or add the address to authorized recipients in Account Settings. "
welcome to SO.
Please have a deeper look at the Laravel official documentation where you can find everything you need to set up the mailgun driver.
Mailgun Driver
To use the Mailgun driver, first install Guzzle, then set the driver option in your config/mail.php configuration file to mailgun. Next, verify that your config/services.php configuration file contains the following options:
'mailgun' => [
'domain' => 'your-mailgun-domain',
'secret' => 'your-mailgun-key',
],
After updating your conf you have to change the MAIL_DRIVER env variable from smtp to mailgun. All the other settings for username, password and so on are not required.

Namecheap\Mailgun - receiving email

I am wondering how to setup namcheap and maligun to receive emails. Currently I am able to send emails with my laravel application through maligun, but I am not sure how to setup maligun to receives replies?
I have seen the options of setting up routes to receive emails to some wanted enpoint, but currently I am not receiving anything on maligun, so I have nothing to forward. I am getting the message:
This is the mail system at host eforward3e.registrar-servers.com.
I'm sorry to have to inform you that your message could not be
delivered to one or more recipients. It's attached below.
For further assistance, please send mail to postmaster.
If you do so, please include this problem report. You can delete your
own text from the attached returned message.
The mail system
: unknown user:
"support#my-domain.com"
Final-Recipient: rfc822; support#my-domain.com
Original-Recipient: rfc822;support#my-domain.com Action: failed
Status: 5.1.1 Diagnostic-Code: X-Postfix; unknown user:
"support#my-domain.com"
How should I set this up?
Hope you register your domain at mailgun, if not then do it here. Once your domain register follow below steps:
1) Get domain and API Key from Mailgun > Doamins > Domain Information page
2) Setup config/services.php:
'mailgun' => array(
'domain' => 'YOURDOMAINNAME',//Place your register domain name here...
'secret' => 'API Key',//Place your API Key here...
),
3) Setup .env:
MAIL_DRIVER=mailgun
MAIL_HOST=smtp.mailgun.org
MAIL_PORT=587
MAIL_USERNAME=USERNAME
MAIL_PASSWORD=YOURPASSWORD
MAIL_ENCRYPTION=tls
4) Check with sending mail from laravel application.
That's it...

MailGun Laravel - Cant send to gmail

I have mailgun setup and working with my custom domain name, as in, I can send test emails to me#mydomain.com but when I try to send to gmail I get the following error.
ClientException in RequestException.php line 107:
Client error: `POST https://api.mailgun.net/v3/mydomain.com/messages.mime` resulted in a `400 BAD REQUEST` response:
{
"message": "Please activate your Mailgun account. Check your inbox or log in to your control panel to resend the act (truncated...)
My mailgun account is setup to work with my domain name correctly and my custom email address doesn't match my site domain name and mail gets delivered to it from mailgun no problems...
MAIL_DRIVER=mailgun
MAILGUN_DOMAIN=mydomain.com
MAIL_HOST=smtp.mailgun.org
MAIL_PORT=587
MAIL_USERNAME=postmaster#mydomain.com
MAIL_PASSWORD=ljhasdlkfhklahsdfklhklasdhflkhasdlkfhkhasdkflh
MAILGUN_SECRET=key-asdflkhjaklsdfkljaslkdfjlkjasdfkj
MAIL_FROM=postmaster#mydomain.com
MAIL_ENCRYPTION=tls
Its weird that when trying to send to a gmail address it gives tells me I need to activate my mailgun account but when sending to a custom domain name address its works perfectly, anyone have any ideas.. Here is the function I am using to send the emails
Mail::send('emails.recontact', ['title' => $title, 'content' => $content], function ($message) use ($request){
$message->from( 'me#mysite.ie', $request->input('name') );
$message->to('myname#gmail.com');
$message->subject("Website Enquiry");
});
You may need to activate you account.
Please login to your mailgun account and make sure there is no a yellow message on the top of the screen that said:
"Please activate your account to start sending emails. We sent an activation email to {your_email}. Resend activation. Update email address."
This solved my problem :)
I am working on mailgun but i faced different problem when recipient reply mail stores instead of delivered

Laravel 5 google mail smtp issue

I am using laravel 5 for sending mail using google smtp. in my env file i set
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME={user}
MAIL_PASSWORD={pass}
and in my route
get('sendemail', function () {
$data = array(
'name' => "Learning Laravel",
);
Mail::send('emails.welcome', $data, function ($message) {
$message->from('alam.ifta#gmail.com', 'Learning Laravel');
$message->to('ifta123#gmail.com','Bappa')->subject('Learning Laravel test email');
});
return "Your email has been sent successfully";
});
it send email successfully, but in my inbox i see that the sender is not alam.ifta#gmail.com but from that account which i use in .env file. Where is the problem. Thank you.
Gmail does not let modify the address your emails come from. It's intended for personal use, not a server's outgoing mail.
If you want that, you need to use an email service designed for sending such emails. Laravel supports many of them out-of-the-box like Mailgun, Mandrill, and Amazon SES. Each has a generous free tier.

Resources