Facing issue in mail function
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
See the answer, may be it will help you.(Please see the last one)
Relay access denied on sending mail, Other domain outside of network
https://jefferyland.wordpress.com/2013/05/28/essential-exchange-troubleshooting-send-email-via-telnet/
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
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.
链接地址: http://www.djcxy.com/p/69348.html下一篇: 面对邮件功能的问题