0

I have tried a lot of solutions from questions on stackoverflow.com and everything looks fine to me, But I still can't send emails

php.ini configuration

sendmail_path = "D:\wamp\sendmail\sendmail.exe -t -i"  // i check with both double and single slashes 
sendmail_path = "D:\\wamp\\sendmail\\sendmail.exe -t -i"
SMTP = localhost
smtp_port = 25 // tried with 465 port as well

php code

$headers = 'MIME-Version: 1.0' . '\r\n';
$headers .= 'Content-type: text/html; charset=iso-8859-1' . '\r\n';
$headers .= 'From: humaaa@outlook.com' . '\r\n';
$rs = mail('iqra@gmail.com','subject','body message',$headers);
echo ($rs) ? "Success": "Fail";

With PHPMailer tried with phpmailer class as well.

$m = new PHPMailer();  

$m->IsSMTP();
$m->Host = "my_domail.com";
$m->Port = "25";
$m->SMTPAuth = false;
$m->Username = 'humaa@my_domail.com';
$m->Username = 'xxxxxxxx';

$m->FromName = 'Huma';
$m->From = 'humaaa@outlook.com';
$m->AddAddress('iqra','iqra@gmail.com');
$m->Subject = 'This is PHPMailer test';
$m->Body = 'This is PHPMailer test here i am going to make you sure!';

$rs = $m->Send();
echo ($rs) ? "Success": "Fail";

I have even tried with swift mailer, but still fail to send. What do I need to do?

Epodax
  • 1,828
  • 4
  • 27
  • 32
Humaira Naaz
  • 280
  • 2
  • 12
  • locahost doesn't works as a SMTP server, upload your content to a valid server with SMTP installed, and then go for the mail call. – Firas Rassas Mar 09 '16 at 08:07
  • Read Here - http://blog.techwheels.net/send-email-from-localhost-wamp-server-using-sendmail/ – Rahul Mar 09 '16 at 08:08
  • https://www.jacmoe.dk/blog/2011/october/how-to-send-test-emails-using-php-mail-from-your-local-wamp-installation. – Rahul Mar 09 '16 at 08:10
  • Have you had a look in the send mail folder. Usually there is `error.log` file that will help – Jacques Koekemoer Mar 09 '16 at 08:10
  • error.log file contains this message `Message is missing sender's address` – Humaira Naaz Mar 09 '16 at 08:12
  • Though you've given example code, you don't say how it's failing or show any errors. In PHPMailer, set `$mail->SMTPDebug = 2;` and show the output. On linux it's quite normal to run a mail server on localhost. You've based yoru code on an obsolete PHPMailer example, so make sure you're running [the latest version](https://github.com/PHPMailer/PHPMailer). – Synchro Mar 09 '16 at 10:04
  • @Synchro there was no error either in `PHPMailer` or `mail()` just return false – Humaira Naaz Mar 09 '16 at 11:19
  • You didn't read what I said. – Synchro Mar 10 '16 at 12:48

0 Answers0