I have an issue regarding debian server. The same code I uploaded on cloud server and the contact form (with php) is working properly and is sending email.
I tested exactly the same code in our server in the office with Debian and it does not shows any error but we could not accept emails from contact form.
Thank you in advance
You can't send emails from local server directly
You can take a look at this question
Send email from localhost
localhost term means it's not equipped with mail capability
even though you can try this code to know if it has built in mail server or not
if (mail('email address','subject','message') === true){
echo 'SENT';
}else{
echo 'NOT SENT';
}
Related
i have sendmail set up on Ubuntu 12.10, Apache 2.2 and I can now successfully send emails from my local server using php mail() function. I just wanted to know how do i send mail to my server from gmail or perhaps just send mail to my local server from my local server...
I have tried finding my IP addess and sending a mail from my gmail account to somefakeid#myip and i dont seem to see any mail in /var/mail directory..
and by the way just confirming, any recieved mail will be stored in from of a text file in /var/mail whose name will be the username to which the mail was sent right?
i dont see any file named somefakeid...
Please help...
(Isn't there any PHP inbuilt function which checks for any received mail?)
You can use phpmailer class to connect to a remote or gmail server and than send email.
refer to the following link for more information: http://phpmailer.worxware.com/?pg=examplebgmail
You need couple of things, you need a domain and a mx record. when you have the domain you point your mx record to point to your IP and make sure port 25 is open to receive email.
Here is the code I have in contact.php:
<?php
mail('philovesdogs#gmail.com','sdf','sadfsad');
echo 'Ok';
?>
I put the echo in just to make sure that PHP was working on the page. I uploaded the page to my LAMP server and opened the page. I saw ok. I checked my email however (and my Spam folder) and no email was sent.
You need to configure and keep running SMTP server. Review questions like this: Configuring LAMP to Send Mails
I am trying to send out password reset links for when users forget their password to login to a system I am creating. The problem is, the smtp server is supposedly not configured on the server my system is hosted on. So whenever I try to use the php mail() function to send an email to an internal email address, the emails fail to send, but outside email address (tested with a gmail account), the emails go through. I believe this is because my server is sending directly out to the internet instead of passing through an internal smtp server to resolve where our domain emails should be sent. I was wondering if anyone knew how to configure this on an Xserve or if they knew how to specifically tell the php mail() function where to initially send the email. Any help or pointing in the right direction would be extremely helpful.
Thank you!
mail() doesn't send mail, it just hands things over to the local SMTP server. It does NOT reach out to the recipient's server to deliver the mail. In real world terms, mail() walks your letter down the street and drops it into the neighborhood mailbox. After that, it has absolutely nothing more to do with mail delivery.
Check your local SMTP server's logs to see why the local mails aren't being delivered. There should be a line or two saying why it's registered. Perhaps the local MTA (mail-transfer agent, aka the local "mail man") isn't configured properly.
You can control mail() with it's settings.
This might not solve your overall problem, but hopefully it's useful. This related answer has more information.
We just addressed this problem internally here. Hopefully this will help you as well.
Our environment:
Ubuntu 12.04 LTS
PHP 5.3.10
We could telnet into our SMTP server and send mail from our web server, so it wasn't a permissions issue. When attempting to mail externally, all works perfectly. When attempting to mail internally, silent failure.
Our PHP is using sendmail, which by default, attempts to relay mail to 127.0.0.1. Point this at your SMTP server by editing /etc/mail/sendmail.cf. Update the line from:
# "Smart" relay host (may be null)
DS
to
# "Smart" relay host (may be null)
DSyour.smtp.server.com
Restart sendmail and try sending yourself an email via PHP.
This is something that occurs on Parellels’ PLESK server administration software.
Find your ‘main.cf’ configuration file for PostFix, which for CentOS 6, is located at
/etc/postfix/main.cf
If you can’t find it, do a
which postfix
SSH command to at least see where Postfix is on your server.
Then, open the file up through a text editor, or in the Linux shell, and make these lines (should be at the end of the file, around line 677) :
virtual_mailbox_domains = $virtual_mailbox_maps, hash:/var/spool/postfix/plesk/virtual_domains
virtual_alias_maps = $virtual_maps, hash:/var/spool/postfix/plesk/virtual
virtual_mailbox_maps = hash:/var/spool/postfix/plesk/vmailbox
commented out like this :
#virtual_mailbox_domains = $virtual_mailbox_maps, hash:/var/spool/postfix/plesk/virtual_domains
#virtual_alias_maps = $virtual_maps, hash:/var/spool/postfix/plesk/virtual
#virtual_mailbox_maps = hash:/var/spool/postfix/plesk/vmailbox
Then, restart the Postfix service
sudo service postfix restart
Apache while your at it (can’t hurt), and voila! Your email address should be receiving those emails now. This also doesn’t affect any of your regular emails or anything else, either.
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/
I am using a small script of php to send email through my IIS based server. When I try to send mail an error occurrs:
"The specified CGI application exceeded the allowed time for processing. The server has deleted the process."
Although simple php script is working fine, my sample code is given below.
<?php
if(mail('sheery_1#hotmail.com','test subject','test message')){
echo('ok');
} else{
echo('not ok');
}
?>
You must configure your home server as this feature is ready pre configured on hosting servers.
Try to change the php.ini and change the smtp paths etc