-1

I am trying to send email from the server but it's not sending it throws an error. In phpinfo() I checked mail function is enabled, what's wrong why mail is not sending if anybody has idea means please tell me,

This is my code,

<?php
$msg = "test cotent";
$send =mail("xxxxx@gmail.com","My subject",$msg);
if($send) echo 'sent!';
else echo $errorMessage = error_get_last()['message'];
?>

Error,

mail(): SMTP server response: 554 5.7.1 : Relay access denied
Jeeva Chezhiyan
  • 218
  • 1
  • 9

3 Answers3

0

Use PHP MAILER for cross domain mailing that way you can define your ports or if you still want to use mail Function you'll have to set up an email with your hosting eg abc@yourdomain.com else it wont allow you to send. mail function uses default mailer hosting urls

Reuben Gomes
  • 878
  • 9
  • 16
0

mail() function unable to connect with you SMTP that's why you are getting this problem. To solve this problem you can use PHP MAILER library which is available in GitHub. Using php mailer you can define SMTP, PORT etc.

Either you can create a web mail in your server (info@example.com) and use it in your code.

Hope it will help you to send mail.

Alok Paul.
  • 76
  • 2
  • 9