Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

send Gmail from php form

Tags:

php

email

gmail

I have a project to setup an anonymous feedback form to our website. I wanted to have a go at it with php

the general idea is that I would have a password field (give out to our employees) a field for the feed back and a button to

Ive seen this code snippet

<?php
$to = "[email protected]";
$subject = "Hi!";
$body = "Hi,\n\nHow are you?";
if (mail($to, $subject, $body)) {
  echo("<p>Message successfully sent!</p>");
 } else {
  echo("<p>Message delivery failed...</p>");
 }
?>

But im pretty sure with my limited understanding email systems that i can't just send out email (unless i have an open server somewhere which i do not) so i would need to log on to and email server (in my case gmails server)

so how would i do this?

update:

the code above does work but it doesn't come from a corporate account we currently use Google biz apps and that's why I would like to log on to a Google server to send this out.

like image 405
Crash893 Avatar asked Apr 28 '26 04:04

Crash893


1 Answers

Take a look to: http://www.web-development-blog.com/archives/send-e-mail-messages-via-smtp-with-phpmailer-and-gmail/

like image 111
inakiabt Avatar answered Apr 29 '26 18:04

inakiabt



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!