Jump to content

php mail()


Recommended Posts

I have my own scripts for registration/validation. I've only used it on WAMP on my local machine with it's PHP.ini configured to use sendmail.

so it's been a simple use of the mail() function.

 

I have my heliohost email accounts setup. How would i go about using them to mail?

You don't have to go into TOO much detail.

Thanks in advance.

 

PS: I'm new to webhosting so i'm unfamiliar with a lot of things. Just got my account queued yesterday and i've run CPanel once.

My site isn't up yet but it will be today :)

 

Link to comment
Share on other sites

Cool thanks.

One more question:

What email account would the mail be sent from? Does it need authentication (how do i do it, if it needs), do i have to configure it in cpanel? Any special settings to check?

 

I have my code down now, My site still isn't up :( so i figured i'd ask now so i waste not time getting it up.

Link to comment
Share on other sites

What email account would the mail be sent from?

It would be sent from whatever email address you typed into this variable.

########################################
##### CHANGE TO YOUR EMAIL ADDRESS #####
$to       = "your_email@yahoo.com";

As far as settings, nothing special really. You could use a heliohost email or some other account.

Link to comment
Share on other sites

Kinda goes against the logic of calling it '$to' doesn't it?

Also, It's a contact us form so i'd expect the message to come to MY email ID rather than from it...

 

Yes, I'd like use heliohost's email. I just need to know whether i have to configure something to use a certain email by default or something.

And, more importantly, whether it would need authentication.

Link to comment
Share on other sites

Kinda goes against the logic of calling it '$to' doesn't it?

I think you haven't actually looked at the script, or clearly don't understand it. $to is the email address that the email gets sent to. Hence, it's perfectly named.

Also, It's a contact us form so i'd expect the message to come to MY email ID rather than from it...

Yes, it's a contact form. Visitors to this form would be wanting to contact you (or the owners of the website) and send them feedback by typing it into the form and hitting submit. Then the stuff they typed in would be emailed to the email address that you set in the $to variable. The user of the form doesn't ever necessarily even have to see what email address they are sending the info to or whether the form is just dumping it in a file somewhere.

Yes, I'd like use heliohost's email. I just need to know whether i have to configure something to use a certain email by default or something.

Yes, you would have to change the $to line to the email account you want to use.

And, more importantly, whether it would need authentication.

I guess that really just depends a lot on the email address you use.

 

I think you're getting too hung up on the specifics of this particular script. I didn't write it. I don't really care if all the variables exactly how you want them. You asked for an example of how to send an email through php using the mail() function and I linked a premade example that I thought was a great example BECAUSE it has that amazing regular expression. Regexp can be rather annoying to write yourself so this example stuck in my mind.

 

Once again, if something isn't the way you want it just change it so it suits your needs.

 

Ah ha, I also just realized that I misread your post earlier slightly. The from address never really matters on scripts like this. It's more of just a where can I reply to you at?

$email    = $_POST['email'];

The user of the form fills out the 'from' themselves, but like I said feel free to change as needed.

Link to comment
Share on other sites

The php mail() function doesn't require you to set up any email account at your cpanel. It automatically sends the mail through the mail server using your username. If you looked at the email headers from the email being sent it would show something like this:

 

from: user_name@stevie.heliohost.org

 

user_name would be your username.

 

No matter what you specified in the mail function $to and $from, the email headers would show this for tracking purposes.

 

 

 

Link to comment
Share on other sites

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.   Paste as plain text instead

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