1
1
<?php
2
2
3
3
// Replace this with your own email address
4
- $ siteOwnersEmail = 'user@website.com ' ;
5
-
4
+ $ siteOwnersEmail = 'codex.2.0.contact@gmail.com ' ;
5
+
6
+ use PHPMailer \PHPMailer \PHPMailer ;
7
+ use PHPMailer \PHPMailer \Exception ;
6
8
7
9
if ($ _POST ) {
8
10
28
30
29
31
30
32
// Set Message
31
- $ message . = "Email from: " . $ name . "<br /> " ;
33
+ $ message = "Email from: " . $ name . "<br /> " ;
32
34
$ message .= "Email address: " . $ email . "<br /> " ;
33
35
$ message .= "Message: <br /> " ;
34
36
$ message .= $ contact_message ;
44
46
$ headers .= "Content-Type: text/html; charset=ISO-8859-1 \r\n" ;
45
47
46
48
47
- if (! $ error ) {
49
+ if (empty ( $ error) ) {
48
50
49
51
ini_set ("sendmail_from " , $ siteOwnersEmail ); // for windows server
50
- $ mail = mail ($ siteOwnersEmail , $ subject , $ message , $ headers );
51
-
52
- if ($ mail ) { echo "OK " ; }
53
- else { echo "Something went wrong. Please try again. " ; }
52
+ //$mail = mail($siteOwnersEmail, $subject, $message, $headers);
53
+
54
+ // Import PHPMailer classes into the global namespace
55
+ // These must be at the top of your script, not inside a function
56
+
57
+
58
+
59
+
60
+ //Load Composer's autoloader
61
+ require '..\vendor\autoload.php ' ;
62
+
63
+ //$email_id = $_POST['contactEmail'] ;
64
+
65
+ $ mail = new PHPMailer (true ); // Passing `true` enables exceptions
66
+ try {
67
+ //Server settings
68
+ //$mail->SMTPDebug = 2; // Enable verbose debug output
69
+ $ mail ->isSMTP (); // Set mailer to use SMTP
70
+ $ mail ->Host = 'smtp.gmail.com ' ; // Specify main and backup SMTP servers
71
+ $ mail ->SMTPAuth = true ; // Enable SMTP authentication
72
+ $ mail ->Username = 'codex.2.0.contact@gmail.com ' ; // SMTP username
73
+ $ mail ->Password = '' ; // SMTP password [Password Changed and removed from GitHub for sequrity]
74
+ //$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
75
+ $ mail ->Port = 25 ; // TCP port to connect to
76
+
77
+ //Recipients
78
+ $ mail ->setFrom ('codex.2.0.contact@gmail.com ' , 'CODEX_ITER ' );
79
+ $ mail ->addAddress ($ email , $ name ); // Add a recipient
80
+ $ mail ->addAddress ('codex.2.0.contact@gmail.com ' ); // Name is optional
81
+ //$mail->addReplyTo('info@example.com', 'Information');
82
+ //$mail->addCC('cc@example.com');
83
+ //$mail->addBCC('bcc@example.com');
84
+
85
+ //Attachments
86
+ //$mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments
87
+ //$mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name
88
+
89
+ //Content
90
+ $ mail ->isHTML (true ); // Set email format to HTML
91
+ $ mail ->Subject = $ subject ;
92
+ $ mail ->Body = $ message ;
93
+ $ mail ->AltBody = 'Thanks a ton for sending us a message. We were quite lonely here :D . ' ;
94
+
95
+ $ mail ->send ();
96
+ echo 'Message has been sent ' ;
97
+ } catch (Exception $ e ) {
98
+ echo 'Message could not be sent. Mailer Error: ' , $ mail ->ErrorInfo ;
99
+ }
100
+
54
101
55
102
} # end if - no validation error
56
103
66
113
67
114
}
68
115
116
+
117
+
69
118
?>
0 commit comments