i am trying to send the contact form data to email using smtp server . but its not working and i dont know how to configure smtp, i googled it but didn't found any good solution. my php code for email sending is :
// Please specify your Mail Server - Example: mail.example.com.
ini_set("SMTP","ssl://smtp.gmail.com");
// Please specify an SMTP Number 25 and 8889 are valid SMTP Ports.
ini_set("smtp_port","465");
// Please specify the return address to use
ini_set("sendmail_from","chadhar313@gmail.com>");
$to ="chadhar313@yahoo.com";
$yourname = trim($_POST['yourname']);
$email = trim($_POST['email']);
$subject = trim($_POST['subject']);
$message = trim($_POST['message']);
$header = "Contact Form";
$message = "Name: $yourname \r\n Email: $email \r\n Subject:
$subject \r\n Message: $message";
$headers = "From:" . $yourname;
$mailsent = mail($to, $header, $message, $headers);
if($mailsent) {
$sent = true;
PHP must be configured correctly in the php.ini
file with the details of how your system sends email. Open php.ini
file available in the /etc/
directory and find the section headed [mail function]
.
Windows users should ensure that two directives are supplied. The first is called SMTP
that defines your email server address. The second is called sendmail_from
which defines your own email address.
The configuration for Windows should look something like this:
[mail function] ; For Win32 only. SMTP = smtp.secureserver.net
; For win32 only sendmail_from = webmaster@tutorialspoint.com
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.