Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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:

mail('toemail@gmail.com',$subject,$message);

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

mail($to,$subject,$message);

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:
    'toemail@gmail.com'
share|improve this question
    
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

1 Answer 1

up vote 1 down vote accepted

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:

http://10.1.1.11/sendEmail.php?email=toemail@gmail.com

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!

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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