Lodius2000 Posted February 5, 2009 Share Posted February 5, 2009 to dispel all calls for me to post some code, here is how I use the mail() function: <?php $to = $email; $subject = 'Activation email from '. $sitename; $message = "Thank you for registering at $sitename\n your Username is $username\n your password is $_POST[password]\n please follow this activation link to make your account active\n $active_link"; $message = wordwrap($message, 70); $headers = 'From: ' . $admin_email . "\r\n" . 'Reply-To: ' . $admin_email . "\r\n"; mail($to, $subject, $message, $headers); ?> Now on to my issue, the mail gets sent every time, and it gets recieved every time, but time is a relative thing, sometimes the mail comes into my inbox in about 30 seconds, sometimes longer than 6 hours. I have a trouble ticket in with my host's tech support, but they are giving me the runaround, they tested it and got mail into their inbox in 9 mins, so they said the problem was solved... I just tested again, more than 2 hours later I recieved the email. My host wants me to give them the full headers of the emails, so I do and they never think its a problem... The first time I tried this experiment I sent one email to myself on yahoo and one to my work email at the same time. I recieved both, within minutes of eachother, 6 hours later, so that tells me the problem is not on the recieving end. I would like something more than "Something is wrong" to tell my host, I dont think its php, but they dont seem to get that it is their system, what can I tell them to get them to understand. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/143870-php-mail-issues/ Share on other sites More sharing options...
sKunKbad Posted February 5, 2009 Share Posted February 5, 2009 I think you should go with the most simple mail() implementation, just for testing purposes, and see what happens. <?php // A test script for sending mail. Put your email address below // and open this script in your browser. $ADDR = "you@yourhost.com"; if (mail($ADDR,"Testing","This is a test")) echo "Mail function succeeded<br />"; else echo "Mail function FAILED<br />"; ?> if that doesn't work try this: <?php // A test script for sending mail. Put your email address below // and open this script in your browser. $ADDR = "you@yourhost.com"; if (mail($ADDR,"Testing with -f","This is a test","From: $ADDR","-f$ADDR")) echo "Mail function succeeded with -f parameter<br />"; else echo "Mail function FAILED with -f parameter<br />"; ?> If you do these tests, and one of them should obviously work, then your host really can't say much about the script. You should check the headers, and see what's happening as it relays. Some ISPs or mail services can hold an email back from being delivered for various reasons. Quote Link to comment https://forums.phpfreaks.com/topic/143870-php-mail-issues/#findComment-755030 Share on other sites More sharing options...
Lodius2000 Posted February 5, 2009 Author Share Posted February 5, 2009 what does the -f do? Quote Link to comment https://forums.phpfreaks.com/topic/143870-php-mail-issues/#findComment-755036 Share on other sites More sharing options...
sKunKbad Posted February 5, 2009 Share Posted February 5, 2009 the -f is the "f option" and is a "from name" Quote Link to comment https://forums.phpfreaks.com/topic/143870-php-mail-issues/#findComment-755038 Share on other sites More sharing options...
Lodius2000 Posted February 5, 2009 Author Share Posted February 5, 2009 ok ran the test and both emails have arrived, speedily, heres a screenshot of my inbox, what does this tell me/what can I tell my host [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/143870-php-mail-issues/#findComment-755040 Share on other sites More sharing options...
sKunKbad Posted February 5, 2009 Share Posted February 5, 2009 ok ran the test and both emails have arrived, speedily, heres a screenshot of my inbox, what does this tell me/what can I tell my host The -f option looks more "normal", but if they both came through fast, then perhaps something in your version of the email was being flagged as spammy? There's a lot to think about when sending HTML and/or text email. Certain keywords or phrases may count against you. Having links in your email may count against you. MTAs can greylist you, and make you wait XX amount of minutes before your email goes through. They may do a reverse MX lookup on your email address to verify that it actually exists, etc, etc. Once when I was testing my server, I sent myself a virus to see if my virus checker was functioning, and somebody somewhere red listed my server and I couldn't send emails! I don't remember who it was, but there is a lot going on when you send an email, and most people don't have a clue. I don't think there was a real problem with your host. You probably just have to work on what you are sending. Quote Link to comment https://forums.phpfreaks.com/topic/143870-php-mail-issues/#findComment-755083 Share on other sites More sharing options...
killah Posted February 5, 2009 Share Posted February 5, 2009 Also. Your word wrap function need's 3 params. That's from The team who created PHP Quote Link to comment https://forums.phpfreaks.com/topic/143870-php-mail-issues/#findComment-755092 Share on other sites More sharing options...
Lodius2000 Posted February 5, 2009 Author Share Posted February 5, 2009 killah "The line is broken using the optional break parameter. Defaults to '\n'." since I already included \n's i left the break parap out, also if you are ok with the 75 char width of wordwrap, you dont even need to include that, as it defaults to 75 Quote Link to comment https://forums.phpfreaks.com/topic/143870-php-mail-issues/#findComment-755447 Share on other sites More sharing options...
Lodius2000 Posted February 5, 2009 Author Share Posted February 5, 2009 sKunKbad, or anyone else, so why the varying delay in delivery... my host responded to my most recent full header post, and they said that there was a 40 min delay on the recieving server (my email address), but I just ran the same script again twice and it was an instantaneous delivery on both attempts, also, it is now the same time of day of the 40 min delay yesterday Quote Link to comment https://forums.phpfreaks.com/topic/143870-php-mail-issues/#findComment-755498 Share on other sites More sharing options...
sKunKbad Posted February 6, 2009 Share Posted February 6, 2009 sKunKbad, or anyone else, so why the varying delay in delivery... my host responded to my most recent full header post, and they said that there was a 40 min delay on the recieving server (my email address), but I just ran the same script again twice and it was an instantaneous delivery on both attempts, also, it is now the same time of day of the 40 min delay yesterday Maybe there are queues that are being processed at each relay or MTA, and this creates a bottleneck that there is no way of knowing. Other than some semi-educated guesses, I just don't know. Quote Link to comment https://forums.phpfreaks.com/topic/143870-php-mail-issues/#findComment-755761 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.