473,386 Members | 1,908 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

google smtp with php

116 100+
how can we use google smtp server to send mail using php

here's my current php script

Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  
  3. $toName        = "my name";
  4. $toEmail    = "myemail@example.org";
  5. $subject    = "success";
  6.  
  7. $name        = $_POST["name"];
  8. $email        = $_POST["email"];
  9.  
  10.  
  11.  
  12. $headers = "From: Your Name <myemail@example.org>" . "\r\n";
  13. $headers .= "Reply-To: Your Name <myemail@example.org>" . "\r\n";
  14. $headers .= "X-Mailer: PHP/" . phpversion();
  15.  
  16. $message= "name: $name
  17. email: $email
  18.  
  19.  
  20. ";
  21.  
  22. $replySubject    = "Mail from me";
  23. $replyMessage    = "I will reply to your query soon";
  24.  
  25.  
  26. // send email  to You //
  27.  
  28.  
  29.     mail($toName." <".$toEmail.">", $subject, $message, "From: ".$name." <".$email.">");
  30. // send email  to You //
  31.  
  32.     print "process=complete";
  33.  
  34. // send reply email to inquirer //
  35.     mail ($name." <".$email.">", $replySubject, $replyMessage, $headers);
  36. // send reply email to inquirer //
  37.  
  38. ?>
  39.  
Dec 29 '09 #1
5 2880
miraan
24
The smtp server you use is configured on your server, for example, your Apache configuration file. I'm not sure if Google allow everyone to use their smtp server though. You might want to check.
Dec 29 '09 #2
angelicdevil
116 100+
isnt there a way i can send in the remote server details in the php and ask mail function to use the details provided in the script itself
Jan 4 '10 #3
Dormilich
8,658 Expert Mod 8TB
I'm not sure if Google allow everyone to use their smtp server though.
all you need is a google account (usually).
and ask mail function to use the details provided in the script
you might have read that mail() doesn’t use an SMTP server …
Jan 4 '10 #4
angelicdevil
116 100+
so any other way other than mail();
Jan 4 '10 #5
Dormilich
8,658 Expert Mod 8TB
of course. there is e.g. the SwiftMailer library
Jan 4 '10 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Dan Boyle | last post by:
Hi, I am having difficulty connection to an smtp host. I am using the following code but I don't think I fully understand what smtp host can be used. function setSMTPParams($host = null,...
21
by: Nancy | last post by:
Hi, Guys, Is there any other way to use python or mod_python writing a web page? I mean, not use "form.py/email", no SMTP server. <form action="form.py/email" method="POST"> ... Thanks a lot. ...
2
by: RandRace | last post by:
I'm having some problems with a little script i wrote using net::smtp. I originally wrote it in linux where it works perfectly. I tried to use it from windows the other day and it doesn't work. It...
3
by: dale zhang | last post by:
Hi, I write an asp.net web application. It has a “Contact Us” page, where users fill in their email, subject and text and hit send. Then the email will go to my hard coded yahoo email...
1
by: bivin | last post by:
hai i am requesting your technical support. please help me. i have been working with this for five days. the problem is relating with the smtp. i am trying to send an email from the asp.net...
34
by: antonyliu2002 | last post by:
I've set up the virtual smtp server on my IIS 5.1 like so: 1. Assign IP address to "All Unassigned", and listen to port 25. 2. Access Connection granted to "127.0.0.1". 3. Relay only allow...
3
by: IanReardon | last post by:
Is it possible to configure an external SMTP server to route all of your outgoing mail through on Linux? I know in php.ini there is a parameter, but it says its only for windows? Can I do this...
13
by: jcor | last post by:
Hi, I'm trying some code to send a mail with my script. This is it: #!/usr/bin/perl use Net::SMTP; my $smtp_server='62.193.245.15'; my $smtp = Net::SMTP->new($smtp_server) or die "Can't Open...
5
by: jimhill10 | last post by:
I have a perl script that creates an email attachment file from POST data on a web page. This works just fine. I want to customize the email body to contain all of the text data from the file...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.