drmota Posted August 17, 2011 Share Posted August 17, 2011 Hello, Something that's been really bugging me the last days is a problem in PHP, the mail(); function, so here goes. First, my script: $to = "[email protected]"; $subject ="contact form"; $body = "Hello, you have been contacted"; $from = "$_POST['email']; $headers = 'From : [email protected]'."\r\n".'Reply-To: [email protected]'; if (mail($to, $subject, $body, $headers)) { echo "worked"; } else { echo "didn't work"; } I'm using Ubuntu linux and have set up an SMTP server like so: sudo apt-get install postfix And configured it. I have also forwarded TCP port 25 to the server. Problem: I run the script and it echos 'worked', meaning that there was no error. However, I don't get a mail sent into my inbox. :'( Thanks in advance, Drmota Quote Link to comment https://forums.phpfreaks.com/topic/245037-php-mail-and-smtp/ Share on other sites More sharing options...
JKG Posted August 17, 2011 Share Posted August 17, 2011 hotmail and aol are terrible for filtering emails. check your spam. try another email address. Quote Link to comment https://forums.phpfreaks.com/topic/245037-php-mail-and-smtp/#findComment-1258604 Share on other sites More sharing options...
drmota Posted August 17, 2011 Author Share Posted August 17, 2011 So you are saying the SMTP is set up correctly? Quote Link to comment https://forums.phpfreaks.com/topic/245037-php-mail-and-smtp/#findComment-1258734 Share on other sites More sharing options...
JKG Posted August 17, 2011 Share Posted August 17, 2011 you are not sending through the SMTP protocol. if you were, you are more likley to appear genuine. many email providers do not like the mail() protocol. Quote Link to comment https://forums.phpfreaks.com/topic/245037-php-mail-and-smtp/#findComment-1258745 Share on other sites More sharing options...
xyph Posted August 17, 2011 Share Posted August 17, 2011 mail() should use SMTP sockets. You need to check your SMTP server's logs to verify whether the mail was actually sent or not. Assuming you have PHP sey up properly to use your server when you call the mail() function, any debugging beyond that is through your mail server. Quote Link to comment https://forums.phpfreaks.com/topic/245037-php-mail-and-smtp/#findComment-1258770 Share on other sites More sharing options...
drmota Posted August 17, 2011 Author Share Posted August 17, 2011 Thanks, i showed you which SMTP server I installed, any idea where its logs are located? Quote Link to comment https://forums.phpfreaks.com/topic/245037-php-mail-and-smtp/#findComment-1258780 Share on other sites More sharing options...
drmota Posted August 18, 2011 Author Share Posted August 18, 2011 Please answer Quote Link to comment https://forums.phpfreaks.com/topic/245037-php-mail-and-smtp/#findComment-1259086 Share on other sites More sharing options...
synking Posted August 18, 2011 Share Posted August 18, 2011 postfix runs off of the syslog so it depends on how you configured it and what nix version you are running you can try /etc/sys.log or /etc/log or /var/log those might have something regarding it but it depends on how it was setup for logging. Quote Link to comment https://forums.phpfreaks.com/topic/245037-php-mail-and-smtp/#findComment-1259101 Share on other sites More sharing options...
drmota Posted August 18, 2011 Author Share Posted August 18, 2011 This is what it says about the postfix I set-up: (It says this like 200 times): Aug 18 17:43:58 Vojta2 postfix/smtpd[3735]: lost connection after RCPT from 114-42-140-172.dynamic.hinet.net[114.42.140.172] Aug 18 17:43:58 Vojta2 postfix/smtpd[3735]: disconnect from 114-42-140-172.dynamic.hinet.net[114.42.140.172] Aug 18 17:47:18 Vojta2 postfix/anvil[3739]: statistics: max connection rate 1/60s for (smtp:114.42.140.172) at Aug 18 17:43:56 Aug 18 17:47:18 Vojta2 postfix/anvil[3739]: statistics: max connection count 1 for (smtp:114.42.140.172) at Aug 18 17:43:56 Aug 18 17:47:18 Vojta2 postfix/anvil[3739]: statistics: max cache size 1 at Aug 18 17:43:56 Aug 18 18:09:01 Vojta2 CRON[3751]: (root) CMD ( [ -x /usr/lib/php5/maxlifetime ] && [ -d /var/lib/php5 ] && find /var/lib/php5/ -depth -mindepth 1 -maxdepth 1 -type f -cmin +$(/usr/lib/php5/maxlifetime) -delete) Aug 18 18:11:52 Vojta2 postfix/qmgr[1813]: 9F95876042C: from=<nobody@Vojta2>, size=402, nrcpt=1 (queue active) Aug 18 18:11:52 Vojta2 postfix/qmgr[1813]: 3C2DC760425: from=<nobody@Vojta2>, size=373, nrcpt=1 (queue active) Aug 18 18:11:52 Vojta2 postfix/qmgr[1813]: 4E0B1760427: from=<nobody@Vojta2>, size=402, nrcpt=1 (queue active) Aug 18 18:11:52 Vojta2 postfix/smtp[3762]: connect to mx3.hotmail.com[65.54.188.126]:25: No route to host Aug 18 18:12:22 Vojta2 postfix/smtp[3760]: connect to mx3.hotmail.com[65.55.92.184]:25: Connection timed out Aug 18 18:12:22 Vojta2 postfix/smtp[3761]: connect to mx4.hotmail.com[65.55.92.136]:25: Connection timed out Aug 18 18:12:22 Vojta2 postfix/smtp[3762]: connect to mx1.hotmail.com[65.55.92.168]:25: Connection timed out Aug 18 18:12:25 Vojta2 postfix/smtp[3761]: connect to mx3.hotmail.com[65.55.37.88]:25: No route to host Aug 18 18:12:52 Vojta2 postfix/smtp[3760]: connect to mx2.hotmail.com[65.55.37.120]:25: Connection timed out Aug 18 18:12:52 Vojta2 postfix/smtp[3762]: connect to mx1.hotmail.com[65.55.37.104]:25: Connection timed out Aug 18 18:12:55 Vojta2 postfix/smtp[3761]: connect to mx1.hotmail.com[65.54.188.126]:25: Connection timed out Aug 18 18:13:22 Vojta2 postfix/smtp[3760]: connect to mx1.hotmail.com[65.55.92.184]:25: Connection timed out Aug 18 18:13:22 Vojta2 postfix/smtp[3762]: connect to mx4.hotmail.com[65.55.92.136]:25: Connection timed out Aug 18 18:13:25 Vojta2 postfix/smtp[3761]: connect to mx1.hotmail.com[65.54.188.72]:25: Connection timed out Aug 18 18:13:52 Vojta2 postfix/smtp[3760]: connect to mx2.hotmail.com[65.55.92.152]:25: Connection timed out Aug 18 18:13:52 Vojta2 postfix/smtp[3762]: connect to mx1.hotmail.co And then this: Aug 18 13:34:21 Vojta2 postfix/smtp[3102]: 4E0B1760427: to=<[email protected]>, relay=none, delay=75992, delays=75842/0.05/150/0, dsn=4.4.1, status=deferred (connect to mx4.hotmail.com[65.55.37.88]:25: Connection timed out) Any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/245037-php-mail-and-smtp/#findComment-1259150 Share on other sites More sharing options...
synking Posted August 19, 2011 Share Posted August 19, 2011 Yes then either your the ISP is blocking out going mail or the hotmail servers think you are spam and are killing your connection. Quote Link to comment https://forums.phpfreaks.com/topic/245037-php-mail-and-smtp/#findComment-1259363 Share on other sites More sharing options...
phpsycho Posted August 20, 2011 Share Posted August 20, 2011 You have to have a static IP in order to send mail to providers like hotmail yahoo etc If its not static then yahoo or whoever will think its spam and block it from coming through. Although.. it does go through sometimes, usually takes about 4-5 hours though and it ends up in the spam folder. Having the same problem.. and I can't get a static IP. My fix was to host it somewhere else using vps. Quote Link to comment https://forums.phpfreaks.com/topic/245037-php-mail-and-smtp/#findComment-1259657 Share on other sites More sharing options...
trq Posted August 20, 2011 Share Posted August 20, 2011 You have to have a static IP in order to send mail to providers like hotmail yahoo etc If its not static then yahoo or whoever will think its spam and block it from coming through. Although.. it does go through sometimes, usually takes about 4-5 hours though and it ends up in the spam folder. Having the same problem.. and I can't get a static IP. My fix was to host it somewhere else using vps. Another issue is that your pretending to send the mail from a hotmail address. The client will see that the actual server and the From address differ and mark the emails as spam. You should always send your emails from a valid email address on the actual server sending the email. Quote Link to comment https://forums.phpfreaks.com/topic/245037-php-mail-and-smtp/#findComment-1259680 Share on other sites More sharing options...
drmota Posted August 20, 2011 Author Share Posted August 20, 2011 You have to have a static IP in order to send mail to providers like hotmail yahoo etc If its not static then yahoo or whoever will think its spam and block it from coming through. Although.. it does go through sometimes, usually takes about 4-5 hours though and it ends up in the spam folder. Having the same problem.. and I can't get a static IP. My fix was to host it somewhere else using vps. Another issue is that your pretending to send the mail from a hotmail address. The client will see that the actual server and the From address differ and mark the emails as spam. You should always send your emails from a valid email address on the actual server sending the email. My ISP is giving me a dynamic IP, which is static. This may be a problem then ;s Will setting up an Evolution E-mail (im using Ubunty) and using that one to send help? Quote Link to comment https://forums.phpfreaks.com/topic/245037-php-mail-and-smtp/#findComment-1259801 Share on other sites More sharing options...
phpsycho Posted August 20, 2011 Share Posted August 20, 2011 no matter how you send a email to any big email providers it will not work if you have a dynamic ip. Quote Link to comment https://forums.phpfreaks.com/topic/245037-php-mail-and-smtp/#findComment-1259926 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.