Jump to content

Email Script does not reach destination


PHPNuStudent

Recommended Posts

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

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.