0

I'm trying to implement a validation code email into my website, but when I use the mail() function it doesn't send the email. Of the four parameters (Email, Subject, Message, Headers) I've narrowed it down to being the Message that is causing the issue.

This is my code for the Message:

$EmailMessage = "You've almost finished your Website account registration! Just ensure the following is correct and then click the link below to complete the process. /r/nUsername: " . $User . "/r/nPassword: " . $Password . "/r/nEmail: " . $Email . "/r/nDate of Birth: " . $DOB . "/r/nMailing List: " . $MailListMail . "/r/nComplete Registration: http://www.ThisIsAWebsite.com/validate-account.php?User=" . $User . "&ValCode=" . $ValCode;

Let's say for this context that

$User = 'Username'

$Password = 'Password'

$Email = 'email@email.com'

$DOB = '1/1/1990'

$MailListMail = 'Yes'

$ValCode = 'abcd1234A1'

And the function being used is

mail($Email,'Account Creation',$EmailMessage, 'From:AccountCreation@email.com');

If $EmailMessage is set to "Test" or something similar, the message sends fine.

Can anyone see where I've gone wrong?

  • Other than the fact that you should never send a password through email? – Tieson T. Sep 25 '13 at 03:58
  • Look in the SPAM folder and also look for return value of the function to be sure whether the mail was sent or not – Hanky Panky Sep 25 '13 at 03:59
  • it probably lands in spam, as it contains links. – Flash Thunder Sep 25 '13 at 04:00
  • You may also remove bit by bit of your message to narrow it to the cause of it is not being sent. – mathielo Sep 25 '13 at 04:17
  • @TiesonT. Yeah, that's a fair call. I've changed that now. – William Hayward Sep 25 '13 at 06:43
  • @Hanky웃Panky It wasn't showing up in spam, but removing the http:// fixed it. Odd. – William Hayward Sep 25 '13 at 06:44
  • @FlashThunder It wasn't showing up in spam, but removing the http:// fixed it. Odd. – William Hayward Sep 25 '13 at 06:44
  • That's not odd at all. That's what happens with email all the time, some are even discarded. To inbox most of the time you'll need to take some extra steps if there is HTML in the email – Hanky Panky Sep 25 '13 at 06:45
  • @WilliamHayward not that odd... server that you are sending to probably has graylisting on, this means that first few responses it will serve will be `Try again later`, but PHP resigns when You don't have a real mail server. Normally mail server tries again lataer and message passes. This is to avoid spam, and probably after reading link, spam graylisting is being activated. – Flash Thunder Sep 25 '13 at 06:47

0 Answers0