mail() error

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
swraman
Forum Commoner
Posts: 58
Joined: Thu Nov 06, 2008 12:33 am

mail() error

Post by swraman »

I keep gettign this error when using the mail() function.

Warning: mail() [function.mail]: SMTP server response: 550 5.1.0 <<Firstname Lastname> email@gmail.com> missing or malformed local part in C:\Program Files\BitNami WAPPStack\apache2\htdocs\ascprojects\tracker\activity.php on line 114

I think the problem is that I am using gmail as my "send from" address, but I dont know what adress to use...Im hosting on my local machine, and i have my ISP set as the smtp adress in php.ini. What should I use as the "send from" adress?
Last edited by swraman on Mon Feb 16, 2009 4:59 am, edited 2 times in total.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: mail() error

Post by Chris Corbyn »

What's the code you're using?
swraman
Forum Commoner
Posts: 58
Joined: Thu Nov 06, 2008 12:33 am

Re: mail() error

Post by swraman »

Sorry for the confusion...I guess I have to rephrase my question.

What email adress can I use for my outgoing "sendmail_from" address? Gmail certainly doesnt work (and as Google tells me, nothing that requires authentication will work).

So what will work then?
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: mail() error

Post by Chris Corbyn »

The reason I asked to see the code was because the error is telling you that there is a syntax error in the email address ;)

You can use any address in sendmail_from, though there may some constraints in place due to SPF records. Such constraints would not cause the error you're getting though... the mail() function is being used incorrectly or the php.ini setting has a syntax error in it
The key point in the error wrote:550 5.1.0 <<Firstname Lastname> email@gmail.com> missing or malformed local part
Now I'm not 100%, but that looks almost like something along the lines of "<<Firstname Lastname> email@gmail.com>" is being set as the email address rather than "Firstname Lastname <email@gmail.com>".

It's hard to be sure without your code though, so it would be useful if you could post it :)

EDIT | Actually, I guess the outermost < and > brackets in the above code are added by the mail server... I suspect you've got the angle brackets around the "Firstname Lastname" portion, instead of being around the email address where they should be.
swraman
Forum Commoner
Posts: 58
Joined: Thu Nov 06, 2008 12:33 am

Re: mail() error

Post by swraman »

I think all the brackets are added in by the error display or Gmail.

the line of code is:

Code: Select all

mail($email, $subject, $message, $messageHeaders);
And:

Code: Select all

echo(nl2br("$email \n $subject \n $message \n $messageHeaders \n"))
returns:
myemail@gmail.com
Email Subject
Email Content
From: myemail@gmail.com
Im pretty sure the error is with the From: Address. In the input vars ($email, $subject, $message, $messageHeaders), I never specify my name as the sender, just my email address. But in the error it has my name; my guess is that it is erroring b/c it is trying to use my gmail as the sending adress, but when it contacts Gmail's server and gets my name, it doesnt allow it to send under that address since the request is coming from a different domain.

If I omit the $messageheaders var, I get an error telling me to specify an outgoing email address in php.ini. I feel like this is the problem, and I dont know what email address I can use as an outgoing address. But if I'm wrong please correct me. What email adresses can you use as the outgoing email address?
jh_1981
Forum Newbie
Posts: 22
Joined: Fri Jan 30, 2009 6:21 pm

Re: mail() error

Post by jh_1981 »

swraman
Forum Commoner
Posts: 58
Joined: Thu Nov 06, 2008 12:33 am

Re: mail() error

Post by swraman »

There must be a way to do it wothout using an external script, otherwise what would the purpose be in having the function?
How do I use it without an external script? what are the requirements for the email adress so that it will work with the mail() function?
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: mail() error

Post by Chris Corbyn »

What does this show?

Code: Select all

<?php
 
var_dump(ini_get('sendmail_from'));
swraman
Forum Commoner
Posts: 58
Joined: Thu Nov 06, 2008 12:33 am

Re: mail() error

Post by swraman »

Well, I guess I dont need this anymore...on my local test server (local machine) the mail() function didnt work, but on my admin's test servers it apparently has a default email address that it sends from.

Thanks for the help though.
Post Reply