PHPNuStudent Posted November 29, 2009 Share Posted November 29, 2009 Hey Guys look at this code snippet : //read a line from the file $myFile = "MailFile.txt"; $fh = fopen($myFile, 'r'); $theData = fgets($fh); fclose($fh); echo $theData; /send Email $to = "'$theData'"; $subject = "AvailPay new customer Transaction Receipt"; //$message = "Welcome to AvailPay© .\r\nPlease keep this for your records\r\nBelow is your transaction information:\r\n"; $message = "welcome"; if (mail($to, $subject, $message)) { echo("<p>Message successfully sent!</p>"); } else { echo("<p>Message delivery failed...</p>"); } I'm reading a file and then using that line as the email address. I get the "Message successfully sent!" reply - but for some reason the email never arrived at the gmail destination, I also tried it with a yahoo email - same result. The hosting service said the following: If you use the mail() function in your PHP, you do not need to specify an outgoing mail server. If you are using some other method besides mail() in your PHP code, use relay-hosting.secureserver.net for your relay server. I'm using the mail() function, but for some reason the email is not getting to the destination. How would I use the relay-hosting.secureserver.net in PHP??? Or am I missing something. Thanks in advance. Link to comment https://forums.phpfreaks.com/topic/183268-email-script-does-not-reach-destination/ Share on other sites More sharing options...
PHPNuStudent Posted November 29, 2009 Author Share Posted November 29, 2009 Guys I did away with the logic of reading a file with the email address: Its writing the date garbled at times and two if several users registered simultaneously since the form was generating the MailFile.txt as a reference file for sending email each time form data was sent out, sooner or later Two users would be attempting to use the file at the same time, and one of the users would get an error message. So I updated logic to directly use the variable with the email address instead of writing to a separate text file - that did the trick. Link to comment https://forums.phpfreaks.com/topic/183268-email-script-does-not-reach-destination/#findComment-967357 Share on other sites More sharing options...
abazoskib Posted November 29, 2009 Share Posted November 29, 2009 even so, check out http://php.net/manual/en/function.mail.php you should always use the correct headers. Link to comment https://forums.phpfreaks.com/topic/183268-email-script-does-not-reach-destination/#findComment-967360 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.