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.
Related
I am using PHPMailer 5.2.0 for sending mail from localhost using my GMAIL account, it works perfectly, but when I hosted whole contents to a free sub-domain in getmeleave.orgfree.com, I get a error message as follows
SMTP Error: Could not connect to SMTP host.
Please give me solution for this, as it is my final year project.
Thank you
In many case with this issue, Solution like lack of SSL support in PHP. So you need to enable like:
extension=php_openssl.dll
If not solve this?. I suggest you to enable the SMTP debug available on the SMTP configuration page and then try to send an email. It will give you a more detailed story of why you can't send the message.
$mail->SMTPDebug = 1;
Once you set true it will report you what is the SMTP error.
My forum has a problem with sending emails :
i have configured my mail settings as the following :
Mail Type : smtp
SMTP Host : myhost
Port : 587
Username & password : a valid email account on my domain
when i click on forget password to test sending emails i got the following message in error log:
Sender address is not valid for your login. Check your email program settings
I am pretty sure that this account is correct, and i tried to add test mail script to my host with the following code :
<?php
$mail = mail("myEmail", "wahahahahahaahahahahaa","I like spamming your inbox!!!", "From: Myself<your_email#here.com");
if(!$mail){
echo 'mail is not sent!';
} else {
echo 'mail is sent :-)';
}
?>
and it prints
mail is sent :-)
What i am missing here ?
I agree with Eggyal - it sounds like the hosted SMTP server is not allowing mail to be sent from the MAIL FROM address that you are using, with the authentication credentials that you are using.
To confirm this, and to rule-out a problem with the way that your application is trying to send the message - you might want to try sending a message through this SMTP server using a standard mail client (such as Thunderbird or Outlook), and using the same MAIL FROM address and authentication credentials that your application is using. If this fails with the same error, then you've confirmed that the hosted SMTP server is not allowing mail to be sent from the MAIL FROM address that you are using, with the authentication credentials that you are using.
Problem Solved.
I added my gmail on webmaster email, i changed it to domain email user then the problem is solved
I am getting this error despite configuring php.ini to a valid send_from address. I know it is valid because it works when I send it from squirrel mail but when sending mail in php it will just not work. the invalid address presumably refers to the send_from address. so I can't see how it can think it's wrong. here is the php code:
$email="tobiasvogel1#googlemail.com";
$subject = "Your New Password";
$from="admin#dayshare.local";
$message = "Your new password is as follows:
xxxxxxxxxxxxxxxxxxxxxxxxxxx
This email was automatically generated.";
if(!mail($email, $subject,$message,$from)){
echo ("error");
}else echo "success";
and in php.ini:
SMTP = localhost
sendmail_from = admin#dayshare.local
550 Delivery is not allowed to this address
This error means that the sender is trying to send an email to an
address which he is not allowed to send to. This message is generated
after hMailServer has checked the IP range settings. As an example,
the default IP range configuration does not allow external users to
send messages to other external users. This is to prevent people from
using your server to send spam. So if an external user tries to send a
message to another external user, he will get this message.
That is the meaning of the error you are getting. This is from the hMailServer Documentation.
Can you try if the following will work?
<?php
mail('tobiasvogel1#googlemail.com','Test Email','This is a test email.',"From: tobiasvogel1#googlemail.com");
?>
If it doesn't work, then it's probably due to a misconfiguration in your hMailServer and you would need to check your hMailServer Logs.
The 4th parameter of the mail() function is not plain "from". In your code, you are only passing the email address without "From: " - The fourth parameter is for additional mail headers, so you have to format it like this:
mail($email, $subject,$message,"From: admin#dayshare.local\r\nX-Mailer: PHP");
I added another header as an example.
Try this, worked for me:
ini_set("sendmail_from", "info#yourdomain.com");
You need quotes and a semi-colon:
$email="tobiasvogel1#googlemail.com";
here is another solution - WAMP send Mail using SMTP localhost
KEEP IN MIND, everytime, after You change php.ini,
you must restart wamp (! ! !)
p.s. in php.ini, i have used:
SMTP = localhost
smtp_port = 25
sendmail_from = your_user#gmail.com
or if oyu cant edit php.ini, try to insert these lines in your php script.
ini_set("SMTP", "localhost");
ini_set("smtp_port", "25");
ini_set("sendmail_from", "your_user#gmail.com");
I'm trying to send a mail from my own domain server like xyz#mydomain.com in php.
I can successfully send mail using gmail account with pear package. But, sending messages from my own domain fails.
any idea..... how I should send messages from my own domain. I'm getting errors like
authentication failure [SMTP: SMTP server does not support authentication (
code: 250, response: EMU.dnsracks.com Hello [72.18.135.214] TURN SIZE 2097152
ETRN PIPELINING DSN ENHANCEDSTATUSCODES 8bitmime BINARYMIME CHUNKING VRFY OK)]
My mail address is xyz#mydomain.com
Any help would be appreciated.
you don't need to use smtp, just use the phpmailer class.
http://www.askapache.com/php/phpfreaks-eric-rosebrocks-phpmailer-tutorial.html
very easy to use and you'll be sending emails in minutes!
I have currently the following and it's not working. (normally I have a body text and header information, but nothing works)
mail("idealvisions#live.com","Nieuw offerte aanvraag","test");
We'll on my server it did because I'm running php 5 or higher, no problem there. But the contact page is from a client which runs php 4.4 I believe. Now the client is really pushing me to get this fixed but it won't seem to fix. I've tried everything
What's the problem here? is it the php version?
I checked also with phpinfo and have this
sendmail_from no value no value
sendmail_path /usr/local/bin/bgc_webhosting_mailer.sh /usr/local/bin/bgc_webhosting_mailer.sh
This sounds like the Client's server is not set up properly with a mail-sending handler
some ISP's that provide hosting and some free hosting platforms disable the mail function, can you try something like this:
error_reporting(E_ALL);
if (mail ('you#yourdomain.com', 'Test subject', 'Test Body')){
echo 'Mail sent';
}else{
echo 'Mail not sent';
}
if there is an issue with mail() on their server you could consider posting to a mail form on one of your servers and then bouncing them back to a thankyou page on the client's server after.
From the sendmail path, your host uses a custom sendmail program/shell script.
Since the sendmail from isn't set, you have to set it within the mail() function, unless it is hardcoded into /usr/local/bin/bgc_webhosting_mailer.sh in which case you should ask the hosting.
Example setting sender:
mail('recepient#example.com', 'Test subject', 'Test Body', "from:sender#example.com\n");
If the mail() function really is NOT available, then ask your hosting about an alternative, such as their local SMTP server.
You can then use the local SMTP server to send email. Probably the easiest way to do this is donwload an email library that supports sending via SMTP such as PEAR Mail or SwiftMailer for example.
Pear: http://pear.php.net/package/Mail
Swift: http://swiftmailer.org/
If your host does not provide an SMTP server, you should probably look for a different host. However, you can always use a free email service such as Gmail, or Yahoo and send mail through their SMTP.
Also check SeLinux, it can prevent any thread spawned by Apache to send mail. In that case you get no error and no mail.