As with many hosting companies, the php mail() function is disabled in our company as well. The reason for keeping this function disabled is that mail can be sent directly without any
authentication in the php mail() function. This causes the mail to be detected directly as spam and land in the junk folder. With excessive sending, the server IP address is also added to the blacklist.
Now let’s see how to send mail using SMTP connection via
PHP. For this, we will use the PHPMailer library.
You can download the PHPMailer library here.
We upload the class.phpmailer.php,
class.smtp.php, and class.pop3.php files to the same directory as our mail form.
Our mail form code:
IsSMTP(); $mail->SMTPDebug = 1; // debugging: 1 = errors and messages, 2 = messages only $mail->SMTPAuth = true;
$mail->SMTPSecure = ‘ssl’; // ssl for secure connection, tls for normal connection $mail->Host = “mail.siteismi.com”; // Mail server name $mail->Port = 465; // 465 for secure connection, 587 for normal connection $mail->IsHTML(true);
$mail->SetLanguage(“tr”, “phpmailer/language”); $mail->CharSet =“utf-8”; $mail->Username = “isim@siteismi.com”; // Username of our mail address $mail->Password = “PASSWORD”; // Password of our mail address $mail->SetFrom(“isim@siteismi.com”,
“Isim”); // Name displayed when sending mail $mail->AddAddress(“ahmetmakal@msn.com”); // Recipient address $mail->Subject = “Mesaj Basligi”; // Subject heading $mail->Body = “Mesaj icerigi”; // Mail content if(!$mail->Send()){ echo “Mailer
Error: “.$mail->ErrorInfo; } else { echo “Mesaj gonderildi”; } ?>
I wrote the fields that need to be filled in after the code.
Now let’s see the necessary settings for Gmail and Yandex, which provide free mail
service.
Yandex SMTP Settings:
$mail->SMTPSecure = ‘tls’; $mail->Host = ‘smtp.yandex.com’; $mail->Port = 587;
Gmail SMTP Settings:
$mail->SMTPSecure = ‘ssl’; $mail->Host =
‘smtp.gmail.com’; $mail->Port = 465;
SMTP Mail Settings for Ready-Made Scripts:
Now let’s cover how SMTP settings should be configured for ready-made software. Some ready-made software includes the PHPMailer library running in the
background. These settings are made from the admin interface. Below are the settings for some software as examples.
For WordPress, we need to install the WP Mail SMTP plugin. Apply the
following settings from Settings > Email. From Email: isim@siteismi.com From Name: Name Mailer: Send all WordPress emails via SMTP. SMTP Host: localhost or server hostname must be entered. (you can learn the server hostname from us) SMTP Port: 465 Encryption: Use
SSL encryption. Authentication: Yes: Use SMTP authentication. Username: isim@siteismi.com Password: mailpassword
SMTP Settings for vBulletin: vBulletin Options > E-Mail Settings. From here, select Send emails via SMTP Server
SMTP
Server: mail.siteadresiniz.com SMTP Port: 465 SMTP Username: isim@siteismi.com SMTP Password: Your email address password Guaranteed connection to SMTP Server: SSL
SMTP Settings for SMF: To access settings, go to Admin Panel > Maintenance
> Email. Email Type: SMTP SMTP Server: ssl://localhost or ssl://mail.siteadresiniz.com SMTP Port: 465 SMTP Username: isim@siteismi.com SMTP Password: Your email address password
SMTP Settings for OpenCart: To access settings, go to System
> Settings > Mail. Mail Protocol: SMTP SMTP Host: ssl://localhost or ssl://mail.siteadresiniz.com SMTP Username: isim@siteismi.com SMTP Password: Your email address password SMTP Port: 465
You can also send mail via SMTP for other software by making the
same settings.
Leave a Comment
* Your comment will be published after approval.
Comments
0No comments yet. Be the first to comment!