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");
Related
I am trying to send mail using PHP Mailer but there is an issue with setfrom() method
In $mail->setFrom('abcd#abcd.com', 'Jay');
When I use domain name .com mail gets sent and received properly
But when I use . co domain name example $mail->setFrom('abcd#abcd.co', 'Jay');
Its doesn't show any error and says mail sent successfully but mail isn't received on my account.Tried changing google privacy settings.
Note:Not using SMPT kept it to false using default settings
Update:Ok so the thing is It is working but the emails are being receive after hours and hours if I use .co but when I use .com email are received immediately.
Probably server problem.
This sounds like a known problem that's been answered before: gmail does not allow setting arbitrary from addresses. You can preconfigure aliases in settings, but you can't simply start using them at the sending client. You can see the submission conversation by setting $mail->SMTPDebug = 2;, but if it's sending successfully, PHPMailer has no involvement beyond that point.
Ok so the problem was the server (bluehost)
What was happening is whenever the setFrom() had an email address whose sub domain was not '.com' eg: " abcd#abcd.co,abcd#abcd.in" the mail was being received after several hours.
It would work normally if setfrom() was set to a normal address eg: a#gmail.com .
Probably a server issue.
I'm attempting to send some test mail to myself while working on a PHP script. I've researched some other questions and it led me to this tool:
http://www.toolheap.com/test-mail-server-tool/
Others have said that it works perfectly but I'm having trouble using it myself. My php.ini files should be reset to default values as I tried to change the SMTP values at one point, but now they are back to "smtp.wlink.com.np".
For anyone that has used this tool, how does it work? Where do I have to send the e-mail to?
$to = "localhost";
?
Set the php.ini SMTP settings to 127.0.0.1 and port 25.
Send the email to anyone, any address (i.e., send it to obama#whitehouse.gov).
The tool will "intercept" the email, and show it to you. The email will never leave your system.
I am trying to using a simple php email
This is working in my production server. But this is not working in my development server. I am not able to find what server configuration is missing
i am getting the error
Unable to send message to SMTP server. No recipients specified. ite. ready. in "filepath" on line 17
What is this ite?
$toemail="me#example.com";
$subject="subject line" ;
$content="conetent message";
$frmemail = "From:you#example.com" ;
mail( $toemail,$subject,$content,$frmemail ) ;
Can anyone suggest what configuration or php ini setting am missing
dev i access on a port .
i saw the exact same error here
http://www.phpfreaks.com/forums/index.php?topic=134654
http://forums.zend.com/viewtopic.php?t=5151&f=77#p23409
but what can be the some security settings blocking sending email from a different domain??
ZMAil
SMTP localhost
smtp_port 25
sendmail_from no value
The fourth parameter - additional headers - is optional. If is not set the sendmail_from option from php.ini will be used.
If you have access to the php.ini file, try to set the option to you#example.com and remove the 4th argument from mail() function.
Changing these settings on the server seems to have allowed the email to be sent successfully. The settings changed were:
AUTOADD(*YES)
ALWRLY(*ALL)
Allow rely mail is the main one
I would like to make it available for clients to create emails through a web based interface without me having to go to mercury mail program and add a new user every time. i just need a source or script that will allow my clients to create emails on my wampserver email system.
I'm using MercuryMail as my mail host and i'm currently public with my server but need an email creation script that i can put into a web page. Preferably PHP.
Please help,
Thanks.
1) Open the “php.ini“. You should know where it is located because it depends upon the particular server you’re running.
2) Search for the attribute called “SMTP” in the php.ini file.Generally you can find the line “SMTP=localhost“. change the localhost to the smtp server name of your ISP. And, there is another attribute called “smtp_port” which should be set to 25.I’ve set the following values in my php.ini file.
SMTP = smtp.wlink.com.np
smtp_port = 25
3) Restart the apache server so that PHP modules and attributes will be reloaded.
4) Now try to send the mail using the mail() function ,
mail(“you#yourdomain.com”,”test subject”,”test body”);
you might get the warning like this,
Warning: mail() [function.mail]: “sendmail_from” not set in php.ini or custom “From:” header missing in C:\Program Files\xampp\htdocs\testmail.php on line 1
5) Now specify the following headers and try to send the mail again,
$headers = ‘MIME-Version: 1.0′ . “\r\n”;
$headers .= ‘Content-type: text/html; charset=iso-8859-1′ . “\r\n”;
$headers .= ‘From: sender#sender.com’ . “\r\n”;
mail(“you#yourdomain.com”,”test subject”,”test body”,$headers);
Well that’s all, the mail is sent to “you#yourdomain.com” from the localhost.
Note : Some smtp server verifies the email address of the sender so the email address which is in the place of “sender#sender.com” should be a valid and existing email address otherwise mail might not be sent to the “you#yourdomain.com”.
I am getting this error in Joomla while sending the mail.
I am not getting this error every time. But some times its shows me "cannot initiate mail function".
Any solution for this?
That could be any number of things, but a general list of things to check would be first, your Joomla config:
Admin panel > Global Configuration > Server > Mail Settings > Mailer
Make sure that's set to use the PHP mail function. If it is, try making a script called test.php and putting it in the root of your site (where the index.php file is for Joomla). Make that file something like this:
<?php
$to = "you#youremailaddress.com";
if( mail( $to , 'This is a test message.' , 'Is this working?' ) ) {
echo 'Email sent.';
} else {
echo 'Email failed to send.';
}
?>
Make sure you change the $to = line to your email address.
Now go to that script: http://www.yourjoomlasite.com/test.php
You should see the text 'Email sent.' in your browser and then receive an email to that address you entered. If not, then you should contact your hosting provider and ask them to upgrade to the latest PHP version and/or resolve the mail() function issue for you. That is the most raw implementation of sending mail via PHP and if that fails to work then it's got to be an issue with your host.
If you are working in the local server, the mail will not initiate. So host your website in server and try it.
If you have any questions, let me know
If you are using WAMP or similar on your own machine and are getting this message then you need to install a mail server. This is the best solution on Windows.
http://www.toolheap.com/test-mail-server-tool/