0
我想發送聯繫表格數據到使用smtp服務器的電子郵件。但它不工作,我不知道如何配置smtp,我GOOGLE了它,但沒有找到任何好的解決方案。我的電子郵件發送PHP代碼爲:發送本地電子郵件到smtp
// 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","[email protected]>");
$to ="[email protected]";
$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;
可能重複的[從本地主機發送郵件](http://stackoverflow.com/questions/11771854/send-e-mails-from-localhost) –