Jump to content

Recommended Posts

Hello,

 

I am relatively new to PHP.  I am in the process of creating my own website and want to add a contact/comment page.  I am using Win XP+Apache.  I usually use gMail for all my mail and was wondering if it is possible to send email through my gMail account using PHP.  Will the mail() PHP function work for this?  I have tried looking for a tutorial online, but haven't found one yet.  Is there anyone who could point me in the direction about how I can begin with this?  Thanks in advance.

 

RFMeier

Link to comment
https://forums.phpfreaks.com/topic/56060-php-e-mail-help/
Share on other sites

... to send email through my gMail account using PHP ...

WHat do you mean by this? Do you mean you want the email that gets sent from the php email form to be FROM your gmail account? If so, all you have to do is set the email headers so that the from email address is your gmail address. You can do it like this:

 

$from_name = "John Smith";
$from_email = "your_email_goes_here@gmal.com";
$to_email = "to@email.com";
$subject = "This is the email subject";
$message = "This is my message text\n You can write as much as you would like here";

$headers = "From: $from_name<$from_email>\n";
$headers .= "Reply-To: <$from_email>\n";

mail($to_email, $subject, $message, $headers);

Link to comment
https://forums.phpfreaks.com/topic/56060-php-e-mail-help/#findComment-276868
Share on other sites

In theory, no. But it will depend on your host. Some free hosts put some restriction on the use of the mail() function to prevent spam - i've seen some which only allow you to use it if you're paying to use their email too etc. Some hosts dont support the function at all.

Link to comment
https://forums.phpfreaks.com/topic/56060-php-e-mail-help/#findComment-276935
Share on other sites

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.