带有未知文件类型附件的PHP邮件

时间:2016-01-09 08:52:00

标签: php email email-attachments

我想在我的网站上添加发送邮件。用户可以在电子邮件中附加多种类型的文件。所以我写了这段代码来发送邮件。问题是文件类型不正确。例如我附加了一个jpg文件发送到电子邮件。但邮箱中收到的附件是空的或类型错误。 这是我的php邮件文件:

[TestCase("Ruskin", "rusk")] // will fail test
[TestCase("Ruskin", "skin")] // will fail test
[TestCase("Ruskin", "Ruski")] // will fail test
[TestCase("Ruskin", "Ruskin")] // will fail test
[TestCase("John Yan", "HnYa@123")] // will fail test
[TestCase("Ruskin", "bob")] // will pass test
[TestCase("Ruskin", "ru5k")] // will pass test
[TestCase("Ruskin", "niks")] // will pass test
public void Password_Contain_4_Successive_Characters_Of_User_FullName(string userName, string password)
{
    var groupsOfFour = new List<string>();

    // do checks to make sure password/username are at least 4 characters etc

    string userNameWithoutSpaces = userName.Replace(" ", "");
    for (int i = 0; i < userNameWithoutSpaces.Length; i++)
    {
        groupsOfFour.Add(userNameWithoutSpaces.Substring(i, 4));

        if (i + 4 >= userNameWithoutSpaces.Length)
            break;
    }

    Assert.IsEmpty(groupsOfFour.Where(s => password.IndexOf(s, StringComparison.InvariantCultureIgnoreCase) > -1));
}

0 个答案:

没有答案