I have a very peculiar problem... I have a Ubuntu Server 12.04 with LAMP installed and ssmtp installed and configured properly... Now I can send mails from my terminal with and without sudo. This tells me that my ssmtp configuration is correct.

I can send mail from my php script using:


But, when I replace the toEmail with a variable containing the string of the email, I want to send to, like:


Then in this case the mail is not sent, and instead gmail tells me that I have entered the wrong address... Gmail displays that address as 'toemail@gmail.com'... While in the first case the address in the email which is received, is received without quotes...

I have searched a lot and I just cant find an answer...

This is the message I receive:

Delivery to the following recipient failed permanently:
  • How are you assigning the $to variable? What's that line of code look like? – Ed Manet Dec 23 '12 at 23:28
  • it looks like this $to=strval($_GET['email']); its fetched through the URL of the web service this code is present in... and in the URL the value shows up as email='toemail@gmail.com' – ArslanW Dec 23 '12 at 23:55

With a little head banging I have been able to solve this problem...The trick is to send the email in the URL without the quotes...Example:

NOw the email in here is without the quotes... Now the mail() function in PHP will work with ssmtp, but the database queries wont. For database queries to work with the variable the email will be stored in, you just have to add single quotes around it...Cheers!

| improve this answer | |
  • Exactly where I what I thought it was. – Ed Manet Dec 24 '12 at 14:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.