473,383 Members | 1,801 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,383 software developers and data experts.

Contact us form

havealot
I've made a form form (contact us) page , with 3 fields:
[Email,Subject and Message]
it's cool for now but what happens is when someone submits the form (send an email), it sends the mail from the host email I uploaded my site on .

what I want is to receive the message to my gmail accout: xxx@gmail.com, from the email that the user wrote it in the email field: aaa@bbb.ccc , not from my host email which is: xxx@myhost.com .

---------------------------------
this is my part of code:

Expand|Select|Wrap|Line Numbers
  1. //my email
  2. $to = 'xxxx@gmail.com';
  3.  
  4. //subject
  5. $subject  = $this->subject;
  6.  
  7. //message
  8. $message .= $this->message;
  9.  
  10. //headers
  11. $headers  = "From: ";
  12. $headers .= $this->email;
  13. $headers .= "\nReply-To: ";
  14. $headers .= $this->email;
  15.  
  16. mail($to, $subject, $message, $headers);
  17.  
------------------------------------------

I hope you can help me..
thanks in advance
Jul 11 '15 #1
1 1441
computerfox
276 100+
I believe this depends on how the SMTP is configured for PHP.
You can however still try this code:

Expand|Select|Wrap|Line Numbers
  1. require_once "Mail.php";
  2.  
  3. $from = '<from.gmail.com>';
  4. $to = '<to.yahoo.com>';
  5. $subject = 'Hi!';
  6. $body = "Hi,\n\nHow are you?";
  7.  
  8. $headers = array(
  9.     'From' => $from,
  10.     'To' => $to,
  11.     'Subject' => $subject
  12. );
  13.  
  14. $smtp = Mail::factory('smtp', array(
  15.         'host' => 'ssl://smtp.gmail.com',
  16.         'port' => '465',
  17.         'auth' => true,
  18.         'username' => 'johndoe@gmail.com',
  19.         'password' => 'passwordxxx'
  20.     ));
  21.  
  22. $mail = $smtp->send($to, $headers, $body);
  23.  
  24. if (PEAR::isError($mail)) {
  25.     echo('<p>' . $mail->getMessage() . '</p>');
  26. } else {
  27.     echo('<p>Message successfully sent!</p>');
  28. }
  29.  
http://stackoverflow.com/questions/7...rom-a-php-page
Jul 11 '15 #2

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

Similar topics

9
by: Jason | last post by:
I'm struggling with this email code and I'm not php freak since I'm starting to learn php stuff. Could use some help... It seems that I get too many parse errors all over and cannot figure went...
20
by: Steevo | last post by:
For some reason I can't seem to get the contact form on our website to work any longer. I think I must have something wrong in the script because I keep getting an "Internal Server Error" upon...
0
by: Benjamin Bittner | last post by:
Hallo NG, ive searched a lot in some google groups, and found many threads, but nothing that helped me. Here is the scenario: I have an aspx page which loads a user control in page.onInit like...
0
by: rarkin | last post by:
I'd like to find out the best way to have a customized Outlook Contact form be programmed to email a summary of all the Contact fields data to someone's email address. If the Contact form doesn't...
3
by: John | last post by:
What is the easiest way to make the contact form show on the front page. Meaning on want to keep the front html page and when someone clicks on the contact us link the front page remains the same,...
0
by: kammaldeep | last post by:
hi, i m newbie 2 PHP & to b frank ... will alwaz be ... i dont think i will go into much details with PHP as my work doesnot include workin with PHP bt i have a forum .. and i want to make a...
5
by: NYXX | last post by:
Here is my Html Code and my Contact.php This is My code in my html <td height="345" valign="top"> <form style="margin:0; padding:0; " action="contact.php" method="get" id="form"> <table...
12
by: colt28 | last post by:
Ok so I found an ajax contact form script but i can't get the b****** to work. I made a bunch of alterations to it and it didn't work so i replaced everything with the original and it still didn't...
3
by: jerry101 | last post by:
Okay, so I have no knowledge with ASP and I was asked to look at this contact form because the emails aren't delivering. I'll post the whole page of code, because I am unsure at what is what...
0
by: jake hathaway | last post by:
hello , i am getting this error message "At least one of the From or Sender fields is required, and neither was found." i have added a contact form all the details are correct as far as i no...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.