我有一个 php 应用程序,它目前正在使用 php mail() 发送电子邮件。我想使用 smtp(最好是 sendgrid)来发送邮件,因为共享服务器有限制/小时。
我的代码如下:
admin_sendmail.php
class sendmail
{
public static function sendAccountActivateMail($to,$activate_code,$user_id,$user_name,$user_pwd)
{
$flg = false;
try
{
$subject = 'Mysite Account Activation';
$message = "Welcome to Mysite! \n";
$message .= "Please activate your account by clicking the link below \n";
$message .= "http://myzone.mysite.com/account_activation.php?command=activate&surebuzz_code=$user_id&activation_code=$activate_code \n";
$message .= "Username: $user_name \n";
$message .= "Password: $user_pwd \n";
$email = "info@mysite.com";
$headers = "From: $email\r\nReply-To: $email";
$flg = mail($to,$subject,$message,$headers);
}
catch(Exception $e)
{
$flg = false;
}
return $flg;
}
}
谁能帮助将其转换为通过 phpmailer/swiftmailer 或 sendgrid 使用 SMTP?我对php很陌生。这是由我失去联系的其他人编码的。
谢谢