Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [PHP] Formularz kontaktowy i wysyłąnie maila
taaniel
post 23.12.2016, 08:14:03
Post #1





Grupa: Zarejestrowani
Postów: 3
Pomógł: 0
Dołączył: 23.08.2013

Ostrzeżenie: (0%)
-----


Witam serdecznie,
podesłałęm mojemu adminowi takie oto zapytanko:
Chcę wysłać maila ze strony torogrowth.com na maila contact@torogrowth.com
( mail w domenie torogrowth.com).

odpisał mi coś takiego:

Witam,
chce Pan wysłać maila z domeny torogrowth.com na inny adres mailowy. Obsługa poczty dla tej domeny jest wydelegowana do google. Należy więc autoryzować się poprzez smtp wysyłając takiego maila.
Należy więc zmodyfikować skrypt, aby łączył się z konkretnym serwerem SMTP i autoryzować się.

Wcześniej mój skrypt miał taką postać:

  1.  
  2. <?php
  3. $to = 'contact@torogrowth.com';
  4. $subject = 'Free Quote from torogrowth.com website';
  5. $from = $_POST['name'];
  6. $email = $_POST['email'];
  7. $phone = $_POST['phoneNumber'];
  8. $message = $_POST['message'];
  9. $headers = 'From: ' . $_POST['message'] . "\r\n";
  10. "Content-type: text/html; charset=UTF-8" . "\r\n";
  11.  
  12. mail($to, $subject, "From: ".$from.$email.$phone.$message, $headers);
  13.  
  14. header('Location: <a href="http://torogrowth.com/?pageurl=contactform&#39%3b%29;" target="_blank">http://torogrowth.com/?pageurl=contactform');</a>
  15.  
  16. ?>
  17.  



i moje pytanie jest następujące: jak to należy ogarnąć, czy trzeba jakiegoś PHPMailer czy coś w tym stylu? Ewentualnie mże jest prostrze rozwiązanie?
Od razu zaznaczam iż moja znajomość PHP jest bardzo początkująca.
Go to the top of the page
+Quote Post
max_mcee
post 23.12.2016, 08:24:25
Post #2





Grupa: Zarejestrowani
Postów: 156
Pomógł: 1
Dołączył: 25.09.2007

Ostrzeżenie: (0%)
-----


Funkcją mail, wydaje mi się że to nie możliwe.
Można to zrobić np. właśnie za pomocą phpmailer.
Przykład z sieci poniżej:

  1. require_once('../class.phpmailer.php');
  2. //include("class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded
  3.  
  4. $mail = new PHPMailer();
  5.  
  6. $body = file_get_contents('contents.html');
  7. $body = eregi_replace("[\]",'',$body);
  8.  
  9. $mail->IsSMTP(); // telling the class to use SMTP
  10. $mail->Host = "mail.yourdomain.com"; // SMTP server
  11. $mail->SMTPDebug = 2; // enables SMTP debug information (for testing)
  12. // 1 = errors and messages
  13. // 2 = messages only
  14. $mail->SMTPAuth = true; // enable SMTP authentication
  15. $mail->Host = "mail.yourdomain.com"; // sets the SMTP server
  16. $mail->Port = 26; // set the SMTP port for the GMAIL server
  17. $mail->Username = "yourname@yourdomain"; // SMTP account username
  18. $mail->Password = "yourpassword"; // SMTP account password
  19.  
  20. $mail->SetFrom('name@yourdomain.com', 'First Last');
  21.  
  22. $mail->AddReplyTo("name@yourdomain.com","First Last");
  23.  
  24. $mail->Subject = "PHPMailer Test Subject via smtp, basic with authentication";
  25.  
  26. $mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
  27.  
  28. $mail->MsgHTML($body);
  29.  
  30. $address = "whoto@otherdomain.com";
  31. $mail->AddAddress($address, "John Doe");
  32.  
  33. $mail->AddAttachment("images/phpmailer.gif"); // attachment
  34. $mail->AddAttachment("images/phpmailer_mini.gif"); // attachment
  35.  
  36. if(!$mail->Send()) {
  37. echo "Mailer Error: " . $mail->ErrorInfo;
  38. } else {
  39. echo "Message sent!";
  40. }


Ten post edytował max_mcee 23.12.2016, 08:26:55
Go to the top of the page
+Quote Post
viking
post 23.12.2016, 09:31:04
Post #3





Grupa: Zarejestrowani
Postów: 6 376
Pomógł: 1116
Dołączył: 30.08.2006

Ostrzeżenie: (0%)
-----


Poza tym w header nie robisz przekierowania na <a href... tylko konkretny adres.


--------------------
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 28.04.2025 - 07:22