wp_mail unable to send emails [duplicate] - php

This question already has answers here:
PHP mail function doesn't complete sending of e-mail
(31 answers)
Closed 6 years ago.
I have a WordPress website installed on my localhost machine and I'm unable to send emails using the function wp_mail. I don't get any error but I can't receive my emails either? Can someone point me on the right direction? Here's an example of my code:
include("wp-mail.php");
$to = 'test#gmail.com';
$subject = 'Hello';
$message = 'Steve';
wp_mail( $to, $subject, $message );
Thanks

wp_mail works similar to PHP's function mail. You can read more about it here. PHP mail function needs access to sendmail binary, as stated in docs, you shouldn't have this configured in localhost, that's why it fails to send emails.
In order to send emails when testing your website in localhost you should configure SMTP to send emails. There's this plugin caled WP Mail SMTP, you can install it here, I use it on most of my WordPress installations and works really grate.
It overides the wp_mail function and enables you to send emails using the Gmail SMTP server, for instance. You can use any SMTP server you want.

Related

PHP sendmail doesn`t send #RU domain Emails [duplicate]

This question already has answers here:
PHP mail function doesn't complete sending of e-mail
(31 answers)
Closed 3 years ago.
I'm using Laravel 5.8 for web development.
I made a short contact form , From where visitors are able to send me email with some data: name, their email, text ect...
I'm facing problem with #ru domain emails. They are not delivered into my inbox
Here is my .ENV
MAIL_DRIVER=sendmail
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=achelashvili22#gmail.com
MAIL_PASSWORD=myemailpassword
MAIL_ENCRYPTION=tls
My code in controller:
$from = 'test#testmail.com';
$to = "achelashvili22#gmail.com";
$subject = "Checking PHP mail";
$message = "PHP mail works just fine";
$headers = "From:" . $from;
mail($to,$subject,$message, $headers);
My form sends emails normally. Problem appears when I input #ru domain emails. when I change test#testmail.com with any Russian Domain email, for example avtandil1994#mail.ru
I'm getting mail Error in eebmail:
achelashvili22#gmail.com
host gmail-smtp-in.l.google.com [64.233.184.26]
SMTP error from remote mail server after end of data:
550-5.7.1 **Unauthenticated** email from mail.ru is not accepted due to domain's
550-5.7.1 **DMARC policy**. Please contact the administrator of mail.ru domain if
550-5.7.1 this was a legitimate mail. Please visit
550-5.7.1 https://support.google.com/mail/answer/2451690 to learn about the
550 5.7.1 DMARC initiative. x1si17683973wrm.306 - gsmtp
I have also done this for my email
Allow Access for Unreliable apps
and also using Mailable, but problem remains to be the same.
It's an issue behind the scenes. It is the kind, how your system delivers mail to the world.
If you have not setup a mail gateway, your system tries to send the mail directly to the mail gate of the receiver; it is identified by the MX record of DNS. And here nearly all mail servers have it own politics, which from and try mails are accepted.
The better way is to use a gateway to your provider and let it distribute the mails. The provider usually wants an authentication of the client. Therefore see the docu of your provider.

Unable to send mail via php using mail() or phpmailer in wamp64 [duplicate]

This question already has answers here:
PHP mail function doesn't complete sending of e-mail
(31 answers)
Closed 4 years ago.
I am creating a login page.For that, after the signup I need to send the mail to the user for verification.Therefore, I need to send mail.To send the mail, I tried with mail() function like this,
<?php
//sending email with the php mail()
mail('mahadev.3333#gmail.com', 'Subject Line Here', 'Body of Message Here', 'From: vidya.5555#gmail.com');
?>
I have configured php.ini file also like below,
[mail function]
; For Win32 only.
; http://php.net/smtp
SMTP = localhost
; http://php.net/smtp-port
smtp_port = 25
; For Win32 only.
; http://php.net/sendmail-from
sendmail_from ="vidya.merahkee#gmail.com"
I am using windows 64-bit.
And also I have tried with phpmailer. But,I didn't find any solution.Since, 2 day I am trying this.I am unable to do this one.
Can anybody help me to solve this?
First of all if you are using the script on production server then ask your admin for the mail function is active or not . Some time on production server it's blocked by Site admin.
Second if you are using this script on localhost server means on your desktop then first you have to use the mail server start.
for example i am considering that you are using XAMMPP on windows then Your have to start the Mercury Mail Server From the XAMPP control panel.
Mercury by default comes with postmaster and newuser two users.
Then You have to download Mozilla Thunderbird mail client and configure the
newuser and postmaster user in mail client by following the Create New account > email using the newuser#localhost and manually configure the pop and smtp server and port . usually default ports.
you can use the sendmail_from ="newuser#localhost"
then check Mercury Mail server is running then test your script.
it will send the mail and you then check it in the Mozilla Thunderbird mail client.
Third : for setting the From: you have to use the header like below
$headers = "From: newuser < newuser#domain.com >\n";
<?php
$send_to = 'postmaster#localhost';
$mail_subject = 'Subject of Your mail';
$message_body = 'Body of your email like message form php script.';
$headers = 'From: newuser#localhost' . "\r\n";
mail($send_to, $mail_subject, $message_body, $headers);
?>
I hope this will solve the problem .
NOTE if you want to send email form localhost to gamil or any other mail site then you have to use the sendmail application or more tutorial Search the google Term like 'Send email via Gmail in PHP '

mail not sent form xampp in MAC Book pro [duplicate]

This question already has answers here:
PHP mail function doesn't complete sending of e-mail
(31 answers)
Closed 6 years ago.
I have this code to send email using smtp, and i got output- Mail sent successfully with following code
ini_set('SMTP', 'mail.veshraj.com.np');
ini_set('smtp_port', 465);
$message = "Hi \n How are you.";
if(mail('veshraj.joshi1#gmail.com', 'Testing Subject for mail function', $message))
{
echo 'Mail sent successfully';
}
But I did not receive any email, this code is in local machine; If smtp not supported in localhost - then how did frameworks like laravel,yii to do so
You are right that you can't send mail on your local host with XAMMP. You need to work on a server that can send mail such as an EC2 instance. Check out: https://laravel.com/docs/5.0/mail and read about how they configure their mail.
They give information how how to send emails to logs instead of recipients as well.

sending mail from localhost without gmail is it possible? [duplicate]

This question already has answers here:
PHP mail function doesn't complete sending of e-mail
(31 answers)
Closed 7 years ago.
I want to send emails using php mail() function using xampp on ubuntu. But its not sent. Please check my code. Do I need to set any email server like gmail for it or I can do it without gmail?
<?php
$address = "kthakkar#argusoft.com";
$subject = 'Test email';
$body = 'If you can read this, your email is working.';
echo "Attempting to email $address...<br />";
if (mail($address, $subject, $body)) {
echo 'SUCCESS! PHP successfully delivered email to your MTA. If you don\'t see the email in your inbox in a few minutes, there is a problem with your MTA.';
} else {
echo 'ERROR! PHP could not deliver email to your MTA. Check that your PHP settings are correct for your MTA and your MTA will deliver email.';
}
?>
If I use smtp gmail account, its sending mails but not using php mail() as I dont want to share my gmail credentials.
try this:
How to configure XAMPP to send mail from localhost?
You can use other mail services, not only gmail. Later, when you have your own server, install your mail server :)

i am not able to send mail using php via localhost [duplicate]

This question already has answers here:
PHP mail function doesn't complete sending of e-mail
(31 answers)
Closed 8 years ago.
I am using ubuntu with xampp. I need to send mail from localhost . I am new to php.Can u help me what are all i need to configure to send mail from localhost?
<?php
$to = "mymail#gmail.com";
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = "othemail#gmail.com";
$headers = "From:" . $from;
mail($to,$subject,$message,$headers) or die("unable to send");
echo "Mail Sent.";
?>
you should try this link to send mail from localhost
http://www.mittalpatel.co.in/php_send_mail_from_localhost_using_gmail_smtp
which gives you insight about how to send mail from localhost using third party SMTP server.
You should send email using SMTP, it will work.It will work in win32. i am not sure about any other.Check following link.
Send email from localhost running XAMMP in PHP using GMAIL mail server

Categories