Jump to content

Recommended Posts

Hi everybody,

I have a form with a file input and several other standard inputs (Name, email, location, etc) and am trying to create a getfile.php to upload a .jpg file to the server and then send the form data and the name of the image file to me by email.

The file upload is fine but I keep getting this error:

Warning: mail(): SMTP server response: 501 5.5.4 Invalid Address in D:\hshome\miwhel\bits-uk.com\uploads\getfile.php on line 97

Here is what I have so far: [url=http://www.bits-uk.com/getfile_no_email.txt]link[/url]

Here is line 97:  mail($emailTo, $emailSubject, $emailBody, $emailHeader);

I can get it to work either way, upload works, email doesn't or email works, upload doesn't, but not both. any pointers on the code would be welcome.

Cheers. :-\



Link to comment
https://forums.phpfreaks.com/topic/13327-upload-image-file-and-form-data/
Share on other sites

I would check your email address for $emailTo in case there is improper formatting (i.e. not name@domain.com).  If you're using the mail() function inside of another function and your $emailTo variable is stored OUTSIDE of that function - make sure to declare it a global variable INSIDE of the function.

function whatever() {
  global $emailTo, $emailSubject, $emailBody, $emailHeader;
  mail($emailTo, $emailSubject, $emailBody, $emailHeader);
}

Just a suggestion.
yeah i think it's to do with the email address itself as well.

have a look at the manual for the allowed formats: http://www.php.net/manual/en/function.mail.php


so it seems like this:
[code=php:0]
$emailTo = '"julie" <julie@bits-uk.com>';
[/code]

should be:
[code=php:0]
$emailTo = 'julie <julie@bits-uk.com>';
[/code]
  • 3 weeks later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.